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
"Ariel Linden" <[email protected]>
To
<[email protected]>
Subject
re: Re: st: Understanding how lincom gets results after margins
Date
Sat, 2 Nov 2013 10:56:15 -0400
Hi Jeff,
You are absolutely correct on both counts. I reran the original model with
only the treatment, time and interaction terms (i.treat##i.time) and got the
two margins commands to produce the same diff-in-diff results.
Also, I ran the margins command with the predict(xb) option and got the same
results as in the original poisson regression model.
Thank you very much for clearing up these issues for me. I now know to
implement the "post" option in -margins-, and that to replicate the
interaction term from the poisson model I need to specify predict(xb) (even
though I will continue to use margins with the "count of events" since that
is my target outcome)...
Ariel
Date: Thu, 31 Oct 2013 16:29:38 -0500
From: [email protected] (Jeff Pitblado, StataCorp LP)
Subject: Re: st: Understanding how lincom gets results after margins
Ariel Linden <[email protected]> is trying to use -lincom- after
- - -margins-, but is not getting the expected result:
> After running a poisson regression, I ran -margins- to get individual pre
> and post values for a treatment and control group. Next, I ran -lincom- in
> order to estimate the difference in differences, ie,. (treatment_post -
> treatment_pre) - (control_post - control_pre).
>
> The results from -lincom- do not produce the same values as when
calculating
> them manually from the table produced by -margins-. Interestingly enough,
> the results from -lincom- are exactly as those produced in the poisson
> regression table for the interaction treatment#period. Can someone explain
> this discrepancy, and explain how lincom got these results?
>
> **** start code****
>
> . margins postperiod , over(pilot ) coefleg
>
> 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]
>
-
----------------------------------------------------------------------------
> ------
>
> lincom (_b[1.pilot#1.postperiod] - _b[1.pilot#0bn.postperiod]) -
> (_b[0bn.pilot#1.postperiod] - _b[0bn.pilot#0bn.postperiod])
>
> ( 1) [imaging_post_index_tot]0b.pilot#0b.postperiod -
> [imaging_post_index_tot]0b.pilot#1o.postperiod -
> [imaging_post_index_tot]1o.pilot#0b.postperiod +
> [imaging_post_index_tot]1.pilot#1.postperiod = 0
>
>
-
----------------------------------------------------------------------------
> --
> imaging_po~t | Coef. Std. Err. z P>|z| [95% Conf.
> Interval]
>
-
-------------+--------------------------------------------------------------
> --
> (1) | .0047102 .0810194 0.06 0.954 -.1540849
> .1635053
>
-
----------------------------------------------------------------------------
> --
>
> * calculating differences in differences manually from -margins- table:
> . di (.0602585 - .0629165) - (.0576589 - .0604865)
> .0001696
>
> **** end code***
- - -lincom- operates on the current estimation results in -e()-. Without
the
- - -post- option in the call to -margins-, this means that -lincom- is
using
the
- - -e()- results from the most currently estimated model. Ariel needs to
specify
the -post- option with -margins- to get -lincom- to work with -margins- own
estimation results.
We notice that Ariel used the -coeflegend- with -margins- without also
specifying the -post- option. -margins- should have produced an error
message, because it otherwise gives the impression that -e(b)- is from
margins
instead of the originally fitted estimation. We will fix this in a future
update to Stata 13.
- - --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/