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: RE: Plotting interactions
From
<[email protected]>
To
<[email protected]>
Subject
st: RE: Plotting interactions
Date
Mon, 30 Sep 2013 11:21:03 +0000
Amal,
Matt Golder has a bunch of .do files that make plotting interactions very easy: https://files.nyu.edu/mrg217/public/interaction.html
It is also worth looking at the associated papers that are highly cited among political scientists working with interactions.
Best,
Kostas
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Amal Khanolkar
Sent: maandag 30 september 2013 10:41
To: [email protected]
Subject: st: Plotting interactions
Hi All,
I'm trying to plot interactions post regression using the following syntax:
The model:
. regress bwtgestage_sd i.ethnicity_bi2#i.smoke2 sex ib2.magecat i.parity ib2.education i.famsit_new ib2.MBMI5 gestage_wk if multibirth==1, vce(robust)
Linear regression Number of obs = 1144571
F( 22,1144548) = 4543.46
Prob > F = 0.0000
R-squared = 0.0820
Root MSE = .94207
--------------------------------------------------------------------------------------
| Robust
bwtgestage_sd | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---------------------+----------------------------------------------------------------
ethnicity_bi2#smoke2 |
1 3 | -.3777867 .0023854 -158.37 0.000 -.3824621 -.3731114
2 2 | -.1160349 .0063877 -18.17 0.000 -.1285545 -.1035153
2 3 | -.4195231 .0107743 -38.94 0.000 -.4406403 -.3984059
3 2 | -.4354954 .0044767 -97.28 0.000 -.4442696 -.4267213
3 3 | -.577776 .0153539 -37.63 0.000 -.6078691 -.547683
|
sex | .0127302 .0017618 7.23 0.000 .0092772 .0161832
|
magecat |
1 | .0813647 .0062532 13.01 0.000 .0691086 .0936207
3 | -.0483047 .0024836 -19.45 0.000 -.0531725 -.0434369
4 | -.0756843 .0028012 -27.02 0.000 -.0811745 -.070194
5 | -.1036756 .0037371 -27.74 0.000 -.1110003 -.096351
6 | -.1385867 .0075963 -18.24 0.000 -.1534752 -.1236982
|
parity |
2 | .308966 .0020534 150.47 0.000 .3049415 .3129905
3 | .4244317 .0026556 159.83 0.000 .4192269 .4296365
|
education |
1 | -.044489 .0029772 -14.94 0.000 -.0503241 -.0386539
3 | .0334391 .0024809 13.48 0.000 .0285766 .0383016
4 | .0482377 .0025474 18.94 0.000 .0432449 .0532304
|
famsit_new |
3 | -.0321022 .0055319 -5.80 0.000 -.0429445 -.0212598
4 | -.023603 .0077085 -3.06 0.002 -.0387113 -.0084947
|
MBMI5 |
1 | -.2915349 .0039634 -73.56 0.000 -.2993029 -.2837669
3 | .249358 .0023809 104.73 0.000 .2446914 .2540245
4 | .3691747 .0042171 87.54 0.000 .3609092 .3774401
|
gestage_wktemp | -.0000848 .0005237 -0.16 0.871 -.0011111 .0009416
_cons | -.0348456 .0209644 -1.66 0.096 -.0759352 .006244
I then use the following :
qui foreach x of var magecat {
sum `x', d
replace `x' = r(p50)
}
predict p
predict se, stdp
tw (line p ethnicity_bi2 if smoke2==2, sort) (line p ethnicity_bi2 if smoke2==3, sort)
I would like to know if the line above 'qui foreach x of var magecat' actually does indicate all categories of all variables magecat onwards as specified in the model including the continuous variable gestaga_wk?
I don't seem to get a graph I was expecting - or at least I can't make sense of it. Have I specified the graph correctly or is there a better way plot interactions from a regression model?
Thanks!
Amal
*
* 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/