Code

This page contains programmes I have written for various papers. The code has been tested extensively but use it at your own risk. Feedback is welcome.

Decomposing Treatment Effects into Extensive and Intensive Margins

This Stata script implements the decomposition used by Attanasio, Kugler & Meghir (AEJ Applied, 2011) and in my paper "Job Search and Hiring with Two-sided Limited Information about Workseekers Skills" with Eliana Carranza, Kate Orkin, and Neil Rankin.

As an example, a labour market intervention might increase both employment and earnings. This decomposition splits the treatment effect on earnings into an extensive margin effect, due to higher employment, and an intensive margin effect, due to higher earnings conditional on employment. See Appendix B of the latter paper for a detailed explanation of the method and comparison to alternative approaches.

This script can be used as an ado file, or run within an existing do file.

Download here.

Nonlinear Difference-in-Differences

This Stata script estimates the nonlinear difference-in-differences model developed by Athey & Imbens (Econometrica, 2006). The file generates graphs and datasets of selected quantile treatment effects on the treated, as well as several extensions proposed in my paper "Academic Peer Effects with Different Group Assignment Policies:"

- adjusting for covariate differences using propensity score reweighting,

- estimating average and inequality treatment effects on the treated.

Download here.

Nonparametric Matching

This Python file implements a nonparametric matching estimator of E[Y|X] for binary Y. The estimator is a weighted average of Y for observations with "similar" values of X. Similar is defined with respect to Mahalanobis distance and the weights depend on inverse distances. This implementation is orders of magnitude faster than using Stata's standard routines, though similar speed gains may be possible using Mata.

This file is used in my paper "Quasi-Experimental Evaluation of Alternative Sample Selection Corrections" with Josh Hyman.

Download here.