There were unbalanced parantheses in my code. Thanks to Kit Baum for
pointing this out!
***********
cap prog drop simnorm
prog simnorm, rclass
vers 9.0
*construct data
drop _all
set obs 1000
g X2=uniform()*3
g X3=uniform()*0.5+2
g Y=uniform()>0.7
gen a = 3*invnorm(uniform())+ 5 //so mean 5, sd 3
_pctile a, p(5)
loc p5 = r(r1)
logit Y a X2 X3, robust
mfx, predict(p) at(mean a=`p5' X2=0)
mat dydxmfx = e(Xmfx_dydx)
ret sca dydxmfxap5 = dydxmfx[1,1]
end
simulate dydxmfxap5 = r(dydxmfxap5), reps(100) : simnorm
*saving("C:\data\sima.dta", replace)
***********
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/