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: marginal effects for simultaneous changes in interacted variables


From   David Quinn <[email protected]>
To   [email protected]
Subject   Re: st: marginal effects for simultaneous changes in interacted variables
Date   Wed, 31 Oct 2012 19:49:47 -0400

Thanks so much for the response, Jeff.  Unfortunately, I am using
Stata 11, so the -contrast- option is not available. It sure would be
nice to have that.

I sort of figured I would need to generate the predictive margins and
then use -post- to calculate the discrete change, but I was wondering
if there was an easier way to do this with -margins, dydx-.  I
understand that there is not.

I have a quick follow-up question.  Does -lincom- in Stata 11 always
calculate the discrete change and associated reliability estimates
(z-scores, p-values, and confidence intervals) the same way as
-contrast- would in Stata 12?  I notice that in the example that you
use, the predictive margin of x1=0, x2=0 is statistically significant
at the 95% level but x1=1, x2=1 is not, yet the discrete change
between the two is statistically significant.  In my data, I am
encountering a similar case where one value is significant at the 95%
level (p=.001) and the other is not (p=.125), and -lincom- is telling
me that the .46 discrete change between the two values is only
approaching significance (p=.08).  This may be a function of my data,
but I'm kind of surprised by the result because when I use King et
al.'s Clarify program to calculate the same exact discrete change, it
is also .46 but highly significant at the 95% level.

On Wed, Oct 31, 2012 at 7:03 PM, Jeff Pitblado, StataCorp LP
<[email protected]> wrote:
> David Quinn <[email protected]> is using -margins- with -logit- results,
> trying to get the change in the predictive margin when x1 and x2 are
> both equal 0 to x1 and x2 both equal 1:
>
>> I am estimating a logit model as such: Y=X1 + X2 + X1*X2 + X3.
>>
>> X1 and X2 are binary predictors, and I have interacted them using
>> factor notation.  X3 is a
>> control variable.
>>
>> I'd like to assess the discrete change/marginal effects in my
>> dependent variable when X1 and X2 simultaneously move from 0 to 1,
>> setting x3 asobserved.
>>
>> I used the following margins command to calculate this change:
>>
>> margins, dydx(X1) at(X2=(0 1))
>>
>> But this is not giving me the change that I desire.  It's giving me
>> the following two changes: 1.) From X1=0, X2=0 to X1=1, X2=0; and 2.)
>> >From X1=0, X2=1 to X1=1, X2=1.
>>
>> But what I want is the change from X1=0, X2=0 to X1=1, X2=1.
>>
>> When you use King et al's Clarify program, you can select specific
>> values for which the change is to be calculated for multiple variables
>> of interest simultaneously, but I cannot seem to get margins to do
>> this.
>>
>> How do I use margins to calculate the change that I desire?
>
> I'll use the auto data with some generated variables, so I can show the steps
> to get what David wants:
>
>         . sysuse auto
>         . gen x1 = mpg > 20
>         . gen x2 = head > 3
>         . logit for x1##x2 turn
>
> In the above I generated binary predictors x1 and x2, used -foreign- for the
> binary response, and -turn- as a control variable.
>
> Here are the results from logit:
>
> ***** BEGIN:
> Logistic regression                               Number of obs   =         74
>                                                   LR chi2(4)      =      44.34
>                                                   Prob > chi2     =     0.0000
> Log likelihood =  -22.86412                       Pseudo R2       =     0.4923
>
> ------------------------------------------------------------------------------
>      foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>         1.x1 |  -1.807144   1.223086    -1.48   0.140    -4.204349    .5900617
>         1.x2 |  -.9829927   1.491344    -0.66   0.510    -3.905974    1.939989
>              |
>        x1#x2 |
>         1 1  |  -2.262084   2.344498    -0.96   0.335    -6.857215    2.333047
>              |
>         turn |  -.7399175   .2046417    -3.62   0.000    -1.141008   -.3388272
>        _cons |   28.62676   8.020097     3.57   0.000     12.90766    44.34586
> ------------------------------------------------------------------------------
> ***** END:
>
> Now David wants to compare the predictive margin where x1 and x2 are both 0 to
> the predictive margin when they are both 1.
>
> Here we use the interaction between x1 and x2 as the margining term to yield
> the predictive margins that David wants:
>
> ***** BEGIN:
> . margins x1#x2
>
> Predictive margins                                Number of obs   =         74
> Model VCE    : OIM
>
> Expression   : Pr(foreign), predict()
>
> ------------------------------------------------------------------------------
>              |            Delta-method
>              |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>        x1#x2 |
>         0 0  |   .4344516   .0756514     5.74   0.000     .2861776    .5827255
>         0 1  |   .3543279   .1092121     3.24   0.001      .140276    .5683798
>         1 0  |   .2823868   .0419118     6.74   0.000     .2002411    .3645325
>         1 1  |   .0519108   .0556121     0.93   0.351    -.0570869    .1609085
> ------------------------------------------------------------------------------
> ***** END:
>
> Now that we have (more than) the predictive margins of interest, we can use
> contrast operators or the -contrast- option to get -margins- to compute the
> discrete differences between them.
>
> The problem with this approach is that we only care about the '0 0' and '1 1'
> margins, so instead we'll use two separate -at()- options.  The first -at()-
> option will identify the '0 0' predictive margin, then second will identify
> the '1 1' predictive margin.
>
> ***** BEGIN:
> . margins, at(x1=0 x2=0) at(x1=1 x2=1)
>
> Predictive margins                                Number of obs   =         74
> Model VCE    : OIM
>
> Expression   : Pr(foreign), predict()
>
> 1._at        : x1              =           0
>                x2              =           0
>
> 2._at        : x1              =           1
>                x2              =           1
>
> ------------------------------------------------------------------------------
>              |            Delta-method
>              |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>          _at |
>           1  |   .4344516   .0756514     5.74   0.000     .2861776    .5827255
>           2  |   .0519108   .0556121     0.93   0.351    -.0570869    .1609085
> ------------------------------------------------------------------------------
> ***** END:
>
> If David is using Stata 11, he'll have to use the -post- option get get
> -margins- to post its results to -e()- and then use -lincom- to compute the
> discrete change.
>
> In Stata 12, David can use the -contrast()- option and specify how he wants
> margins to contrast the levels of -_at-.  Here we use the reference category
> operator, which will always use the first level as the base in the comparison:
>
> ***** BEGIN:
> . margins, at(x1=0 x2=0) at(x1=1 x2=1) contrast(at(r))
>
> Contrasts of predictive margins
> Model VCE    : OIM
>
> Expression   : Pr(foreign), predict()
>
> 1._at        : x1              =           0
>                x2              =           0
>
> 2._at        : x1              =           1
>                x2              =           1
>
> ------------------------------------------------
>              |         df        chi2     P>chi2
> -------------+----------------------------------
>          _at |          1       16.49     0.0000
> ------------------------------------------------
>
> --------------------------------------------------------------
>              |            Delta-method
>              |   Contrast   Std. Err.     [95% Conf. Interval]
> -------------+------------------------------------------------
>          _at |
>    (2 vs 1)  |  -.3825407   .0942169     -.5672024   -.1978791
> --------------------------------------------------------------
> ***** END:
>
> --Jeff
> [email protected]
> *
> *   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/
*
*   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/


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