Skip to content

Instantly share code, notes, and snippets.

@tyleransom
Last active December 22, 2016 21:07
Show Gist options
  • Save tyleransom/153326be8c4b258411113a7f7cf0a2a2 to your computer and use it in GitHub Desktop.
Save tyleransom/153326be8c4b258411113a7f7cf0a2a2 to your computer and use it in GitHub Desktop.
How to compute counterfactual predictions in Stata
sysuse auto, clear
logit foreign i.rep78 c.price c.mpg
predict base if e(sample), pr
preserve
clonevar oldrep78 = rep78
replace rep78 = 4
predict new if e(sample), pr
generat mfx = new-base
replace rep78 = oldrep78
tab rep78 , sum(mfx)
restore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment