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: Re: st: Understanding how lincom gets results after margins
From
[email protected] (Jeff Pitblado, StataCorp LP)
To
[email protected]
Subject
Re: Re: st: Understanding how lincom gets results after margins
Date
Fri, 01 Nov 2013 16:47:44 -0500
Ariel Linden <[email protected]> has a follow-up question about using
-lincom- with -margins- estimation results:
> Thank you Jeff, for your response. I did not know about the "post" option.
>
> That said, I reran the code (as earlier, with now the added
> post option in the -margins- command) and I am not getting the results I
> would expect, and there are some conflicting results from the various
> -margins- commands.
>
> See code below and my comments throughout. Feel free to take this off line
> if necessary...
>
> **** start code ****
> *selected output from poisson regression (diff-in-diff estimate is
> treated#post term)
> ----------------------------------------------------------------------------
> ------------
> | Robust
> imaging_post_index_tot | Coef. Std. Err. z P>|z| [95%
> Conf. Interval]
> -----------------------+----------------------------------------------------
> ------------
> pilot |
> treated | .1664104 .0563062 2.96 0.003 .0560524
> .2767685
> |
> postperiod |
> post | -.0478752 .0665729 -0.72 0.472 -.1783556
> .0826052
> |
> pilot#postperiod |
> treated#post | .0047102 .0810194 0.06 0.954 -.1540849
> .1635053
> -----------------------+----------------------------------------------------
> ------------
>
> * run margins to get individual values for pre and post for treatment and
> controls (with coefl to get code)
> . margins postperiod , over(pilot) post coefl
>
> Predictive margins Number of obs =
> 54794
> Model VCE : Robust
>
> Expression : Predicted number of events, predict()
> over : pilot
>
> ----------------------------------------------------------------------------
> ------
> | Margin Legend
> -----------------+----------------------------------------------------------
> ------
> pilot#postperiod |
> control#pre | .0604865 _b[0bn.pilot#0bn.postperiod]
> control#post | .0576589 _b[0bn.pilot#1.postperiod]
> treated#pre | .0629165 _b[1.pilot#0bn.postperiod]
> treated#post | .0602585 _b[1.pilot#1.postperiod]
> ----------------------------------------------------------------------------
> ------
> * run lincom to get diff-in-diff manually
> . lincom (_b[1.pilot#1.postperiod] - _b[1.pilot#0bn.postperiod]) -
> (_b[0bn.pilot#1.postperiod] - _b[0bn.pilot#0bn.
> > postperiod])
>
> ( 1) 0bn.pilot#0bn.postperiod - 0bn.pilot#1.postperiod -
> 1.pilot#0bn.postperiod + 1.pilot#1.postperiod = 0
>
> ----------------------------------------------------------------------------
> --
> | Coef. Std. Err. z P>|z| [95% Conf.
> Interval]
> -------------+--------------------------------------------------------------
> --
> (1) | .0001696 .0048414 0.04 0.972 -.0093193
> .0096585
> ----------------------------------------------------------------------------
> --
>
> * run margins for contrasts (treated post-pre diff and controls post-pre
> diff)
> . margins r.postperiod@pilot, post
>
> Contrasts of predictive margins
> Model VCE : Robust
>
> Expression : Predicted number of events, predict()
>
> ----------------------------------------------------------
> | df chi2 P>chi2
> -----------------------+----------------------------------
> postperiod@pilot |
> (post vs pre) control | 1 0.52 0.4714
> (post vs pre) treated | 1 0.88 0.3484
> Joint | 2 1.40 0.4970
> ----------------------------------------------------------
>
> ------------------------------------------------------------------------
> | Delta-method
> | Contrast Std. Err. [95% Conf. Interval]
> -----------------------+------------------------------------------------
> postperiod@pilot |
> (post vs pre) control | -.0026417 .0036677 -.0098303 .004547
> (post vs pre) treated | -.0028196 .0030072 -.0087136 .0030744
> ------------------------------------------------------------------------
>
> * run lincom to manually estimate diff-in-diff value
>
> . lincom _b[[email protected]]- _b[[email protected]]
>
> ( 1) - [email protected] + [email protected] = 0
>
> ----------------------------------------------------------------------------
> --
> | Coef. Std. Err. z P>|z| [95% Conf.
> Interval]
> -------------+--------------------------------------------------------------
> --
> (1) | -.0001779 .0047435 -0.04 0.970 -.009475
> .0091192
> ----------------------------------------------------------------------------
> --
>
> *notes: the margins estimates are not the same, and none of the margins
> estimates are the same as the coefficient estimate from the original Poisson
> model.
Ariel appears to be making 2 points about the following estimation setup:
(E) poisson imaging_post_index_tot pilot##postperiod
estimates store poisson
(A) estimates restore poisson
margins postperiod , over(pilot) post
lincom (_b[1.pilot#1.postperiod] - _b[1.pilot#0bn.postperiod]) - (_b[0bn.pilot#1.postperiod] - _b[0bn.pilot#0bn.postperiod])
(B) estimates restore poisson
margins r.postperiod@pilot, post
lincom _b[[email protected]]- _b[[email protected]]
1. The results from (A) and (B) do not match.
2. Neither (A) nor (B) yeilds the value of the fitted coefficient on
1.pilot#1.postperiod in (E).
For 1., I suspect that there are other terms in (E), otherwise the results in
(A) and (B) would match.
For 2, the resulting -lincom-s are not comparable to the estimated
coefficient on the interaction term because -margins- computed the margins
using the default prediction, which is -n- (number of events) instead of -xb-
(linear prediction).
--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/