Code and Data

Code for LASSO

For Stata code, see https://statalasso.github.io/ which documents two Stata packages:

  1. lassopack – a suite of programs for penalized regression methods suitable for the high-dimensional setting where the number of predictors may be large and possibly greater than the number of observations
  2. pdslasso – code for estimating structural parameters in linear models and linear IV models with many controls and/or instruments

A preliminary version of penalized logistic regression for Stata can be installed from github by running the following command in Stata:

Below are links Stata code and Matlab code for running the empirical examples from “High-Dimensional Methods and Inference on Structural and Treatment Effects”. The Stata code includes a stand-alone .ado file that may be used to obtain LASSO and Post-LASSO estimates in Stata.

  1. MATLAB Code
  2. Stata Code

Code for IVQR

Below are links to MATLAB and Ox code for performing IVQR estimation and inference as developed in “Instrumental Quantile Regression Inference for Structural and Treatment Effect Models” (with Victor Chernozhukov) and “Instrumental Variable Quantile Regression” (with Victor Chernozhukov).  The MATLAB code also includes code for performing the weak identification robust inference procedure proposed in “Instrumental Variable Quantile Regression: A Robust Inference Approach” (with Victor Chernozhukov).  Along with the code, each file contains examples illustrating how the code may be implemented; the data for the examples may also be downloaded below.

  1. MATLAB Code
  2. Ox Code
  3. Data for examples

Code for Weak Instrument Robust Inference

Below are links for the Stata code and data used in the empirical example in “A Simple Approach to Heteroskedasticity and Autocorrelation Robust Inference with Weak Instruments” (with Victor Chernozhukov).  The data are taken from Acemoglu, Johnson, and Robinson (2001) “The Colonial Origins of Comparative Development: An Empirical Investigation”.  The code illustrates the basic procedure and may easily be modified for other data sets and to provide inference that is robust to autocorrelation or clustering.

I thank Mel Stephens for noticing a small error in the original code that has been corrected.  Due to this correction, the results produced by running the files given below will differ slightly from those in the published paper.

  1. Stata Code for weak instrument robust inference
  2. Data

Code for Finite Sample Inference for Quantile Regression

Below is a link to MATLAB code used to produce the results in Table 1 and Figure 1 in Chernozhukov, Hansen, and Jansson (2009) “Finite Sample Inference in Econometric Models via Quantile Restrictions.”

  1. MATLAB code for finite sample inference for quantile regression

Code for Sensitivity Analysis for IV (from “Plausibly Exogenous”)

Stata code for IV sensitivity analysis is available through Stata and can be installed in Stata by typing

ssc install plausexog

Documentation is available here. (A big thanks to Damian Clarke for putting together this nice set of code.)

Additional resources:

  1. Stata Code for IV sensitivity analysis (Stata code that produces some of the results from “Plausibly Exogenous” (with Tim Conley and Peter Rossi).  The code illustrates the basic procedure and may easily be modified for other data sets.  The file with the Stata code also includes sample data.)
  2. Review of Economics and Statistics Replication Files (Files to replicate all results from “Plausibly Exogenous” maintained by REStat.)