Dear All,
I estimate a logit model and then I want to compute the (average) marginal effects of the regressors on the probability of a positive outcome. Since my dataset is quite big (roughly 450,000 observations), margins takes ages. Therefore, I tried to work this problem around using predictnl to "manually" compute the required marginal effects. Now consider the following example:
The results of the calculation via margins is the following:
Instead, if I use predictnl, I use the following code:
Then if I summarize both marurban and se1 I get:
Both the (average) marginal effect and the standard errors are slightly different from those obtained using margins. I tried to use nlcom instead:
The result is reported below:
So, both predictnl and nlcom produce the same results, but they are different from those obtained using margins. Reagrding the standard errors, I know that the latter uses Delta method to compute them. So I know that the standard errors could be different. But why the marginal effect is different from the one obtained with margins. In my understanding its magnitude should be the same. Is there any way I can get the identical results using either predictnl or nlcom?
Thanks in advance for your help.
Dario
I estimate a logit model and then I want to compute the (average) marginal effects of the regressors on the probability of a positive outcome. Since my dataset is quite big (roughly 450,000 observations), margins takes ages. Therefore, I tried to work this problem around using predictnl to "manually" compute the required marginal effects. Now consider the following example:
Code:
webuse bangladesh logit c_use urban age children margins, dydx(urban age children)
Code:
Average marginal effects Number of obs = 1,934
Model VCE: OIM
Expression: Pr(c_use), predict()
dy/dx wrt: urban age children
------------------------------------------------------------------------------
| Delta-method
| dy/dx std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
urban | .1784138 .0221528 8.05 0.000 .1349952 .2218325
age | -.0063953 .0016695 -3.83 0.000 -.0096674 -.0031232
children | .0853374 .0117828 7.24 0.000 .0622435 .1084314
------------------------------------------------------------------------------
Code:
egen mage=mean(age) egen mchildren=mean(children) egen murban=mean(urban) predictnl marurban =_b[urban]*(1/(1+exp(-(_b[_cons]+_b[urban]*murban*_b[age]*mage+_b[children]*mchildren))))*(1-(1/(1+exp(-(_b[_cons]+_b[urban]*murban*_b[age]*mage+_b[children]*mchildren))))), se(se1)
Code:
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
marurban | 1,934 .1756926 0 .1756926 .1756926
se1 | 1,934 .0214322 0 .0214322 .0214322
Code:
nlcom (marurban: _b[urban]*(1/(1+exp(-(_b[_cons]+_b[urban]*murban*_b[age]*mage+_b[children]*mchildren))))*(1-(1/(1+exp(-(_b[_cons]+_b[urban]*murban*_b[age]*mage+_b[children]*mchildren))))))
Code:
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
marurban | 1,934 .1756926 0 .1756926 .1756926
se1 | 1,934 .0214322 0 .0214322 .0214322
Thanks in advance for your help.
Dario

Comment