Code and Topics

Use the menus to the right  for code and documents on propensity scores, finite mixture models, and Stata's teffects command.

Please note the copyright notice below. Most of the material on this site will be part of a book on statistics/econometric methods to be published by Cambridge University Press. Read more about it at Happy to receive feedback.

Below are some old code.

MLE estimation

Examples of maximum likelihood estimation in Stata. It's always useful to write down the likelihood function to understand what is being estimated.

- Tobit using method lf [log file]
- Tobit using method d0 [log file]
- Predictions for Tobit models [log file]
- Mixture of two normals [log file]
- Two Tobits [log file]
- Logit [log file]
- Probit [log file]

Regression discontinuity

New version with sharp and fuzzy, plus replicating results of the rdrobust command using lpoly. Rdrobust given a bandiwdht is really a parametric method...

Regression discontinuity designs, Stata code 

Older version: Notes and Stata code from lectures at the University of Chicago. Warning: Some of the code is probably helpful but the notes above are better and more up-to-date. The version below uses the old rdrobust package. You were warned.

Slides (2015 version)
Stata do file
Stata dataset

Standardized differences

stdif.ado command to calculate standardized differences. Syntax is: stdif varname, by(varname) [categorical unequal].

The categorical option uses the binomial formula for the variances (varname variable must be 0/1 indicator). When the sample size is large the normal approximation works fine. Unequal uses the unequal variance option when calculating t-test statistics. Categorical variables are compared using a Chi2 test.


This is an oldie. It just counts the number of missing values. It's long obsolete. Stata now has many ways of reporting missing values. But I still use it and it seems that other people are using it too. You can get it from UCLA. Type "findit tabmiss". I have a copy: