Dear all,
I am running a simulation of the logit model. Each repetition I create a variable called
"a", which is normally distributed. I would like to find the marginal effect of this
variable at the certain percentiles of its distribution. The problem is that I cannot
specify the number of the particular percentile in -mfx, predict(p) at( )-
because I don't know the value in each repetition. So I use the -r( )- from -sum-.
However,my program gives me the error from -mfx- part saying that
'indp5' found where number expected
an error occurred when simulate executed simlognorm
Is there a way to specify the unknown value in -at( )- of -mfx-? Would anybody please help?
Thank you
Anupit
----------------------------------------------------------
program define simnorm, rclass
version 9.0
gen a = sdX1*invnorm(uniform())+ meanX1
sum a, detail
ret scalar ap5 = r(p5)
logit Y a X2 X3, robust
mfx, predict(p) at(mean a=ap5 X2=0)
mat dydxmfx = e(xmfx_dydx)
ret scalar dydxmfxap5 = dydxmfx{1,1]
eret clear
drop a
end
simulate dydxmfxap5 = r(dydxmfxap5), reps(100) saving("C:\data\sima.dta", replace): simnorm
----------------------------------------------------------
*
* 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/