Bookmark and Share

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


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

st: margins / over / dydx


From   Robert Duval <[email protected]>
To   [email protected]
Subject   st: margins / over / dydx
Date   Wed, 4 Jan 2012 03:19:34 -0600

Dear all,

I have a question on the use of the command margins together with the
option over().

Suppose I want to get the prediction for a given outcome by sex in a
probit model (other models would be ok)

use http://www.stata-press.com/data/r11/margex

probit outcome sex##group age distance arm

margins , over(sex)

That is I want the average predicted probability of having a positive
outcome for males and again for females rather than the average
predicted probability with everyone treated as male and then again
with everyone treated as female.

In this particular example Stata gives me

margins , over(sex)

Predictive margins                                Number of obs   =       3000
Model VCE    : OIM

Expression   : Pr(outcome), predict()
over         : sex

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         sex |
          0  |   .0807707   .0061496    13.13   0.000     .0687178    .0928236
          1  |   .2587496   .0103578    24.98   0.000     .2384487    .2790504
------------------------------------------------------------------------------

Now I want the estimated difference 0.2587496 - .0807707  = .1779789
and its standard error.

Is there an easy way to do this without using the post option?

I cannot use dydx as in

. margins, dydx(sex)

Average marginal effects                          Number of obs   =       3000
Model VCE    : OIM

Expression   : Pr(outcome), predict()
dy/dx w.r.t. : 1.sex

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       1.sex |   .0400701   .0164297     2.44   0.015     .0078685    .0722718
------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.


because that actually estimates the difference between the predicted
probabilities assuming first that everyone is a male and then that
everyone is a female, namely it estimates the difference between the
predictions given by

. margins sex

Predictive margins                                Number of obs   =       3000
Model VCE    : OIM

Expression   : Pr(outcome), predict()

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         sex |
          0  |   .1573491   .0125989    12.49   0.000     .1326558    .1820424
          1  |   .1974193   .0100571    19.63   0.000     .1777078    .2171307
------------------------------------------------------------------------------

but as I stated originally this is not the quantity that I am after.

I can of course estimate

margins , over(sex) post

and then proceed "by hand" given that I have the parameter estimates
to differentiate and the variance-covariance matrix. However, I want
to do this for several models and for many different values in the
at() option. So before I program a complicated loop for my specific
problem in hand I wanted to ask if anyone knows a direct way of
obtaining the  difference 0.2587496 - .0807707  = .1779789 and its
standard error.

Many thanks in advance
robert duval
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index