Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

st: Marginal effet and s.e. after logit2

 From Mélanie Lefèvre To "statalist@hsphsun2.harvard.edu" Subject st: Marginal effet and s.e. after logit2 Date Thu, 5 Dec 2013 09:53:07 +0000

```Dear statalist users,

I am trying to use -margins- after the command logit2 (similar to cluster2, from here: http://www.kellogg.northwestern.edu/faculty/petersen/htm/papers/se/se_programming.htm). However, logit2 does not support the predict option p.

. logit2 Y X1 X2, fcluster(state) tcluster(month)
(output hidden)
. estimates esample:
. margins, dydx(t_7) predict(p)
Warning: cannot perform check for estimable functions.
option p not allowed
r(198);

The xb option (default in logit2) works well:
. margins, dydx(X1)
Warning: cannot perform check for estimable functions.

Average marginal effects                          Number of obs   =    1342637

Expression   : Linear prediction, predict()
dy/dx w.r.t. : X1

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
X1 |  -.0270068   .0088744    -3.04   0.002    -.0444003   -.0096132
------------------------------------------------------------------------------

I would like to obtain the marginal effect, as well as a confidence interval for it, expressed in probabilities rather than in linear prediction.

I tried to calculate the marginal effect and the s.e. by hand:
. predict xb, xb
. gen me=exp(xb)/(1+exp(xb))^2*_b[X1]
. matrix V=get(VCE)
. matrix J=r(Jacobian)
. matrix M= J*V*J'
. display sqrt(M[1,1])
The variable 'me' gives me the marginal effect but the s.e. are not displayed because logit2 does not return the Jacobian. I tries the same procedure after logit and it gives me exactly the same result as margins.

I also tried to modify the logit2 ado file to make it accept the p option but fail to do so.

Does someone has any idea of how I could obtain the correct standard errors for the marginal effect (expressed in probabilities) after the command loigit2?

Thanks a lot.

Mélanie.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```