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]

Re: st: margins / over / dydx


From   [email protected] (Jeff Pitblado, StataCorp LP)
To   [email protected]
Subject   Re: st: margins / over / dydx
Date   Wed, 04 Jan 2012 12:59:06 -0600

Robert Duval <[email protected]> wants to compute a comparison of the results
from -margins- with the -over()- option:

> 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?

In Stata 12, -margins- has new options for computing contrasts of margins.
These new features are documented in -[R] margins, contrast-.

For Robert's example above, simply add a contrast operator in the -over()-
option:

	. margins , over(r.sex) contrast

--Jeff
[email protected]
*
*   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