[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Simulation: marginal effect at the 5th percentile

From   "Martin Weiss" <>
To   <>
Subject   st: RE: Simulation: marginal effect at the 5th percentile
Date   Tue, 2 Dec 2008 09:56:05 +0100

Line for the server...

You must dereference your -local- in 

mfx, predict(p) at(mean a= `ap5' X2=0)
On top of that, you do not want a -return scalar- for your r(p5) but a -local-:

loc ap5 = r(p5)

Also note a typo (exchange the curly for square bracket):

ret scalar dydxmfxap5 = dydxmfx{1,1]


-----Original Message-----
From: [] On Behalf Of Supnithadnaporn, Anupit
Sent: Tuesday, December 02, 2008 5:19 AM
To: statalist
Subject: st: Simulation: marginal effect at the 5th percentile

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 

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

simulate dydxmfxap5 = r(dydxmfxap5), reps(100) saving("C:\data\sima.dta", replace): simnorm

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index