Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: Plotting 3way interactions


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: Plotting 3way interactions
Date   Mon, 17 Aug 2009 23:09:53 +0200

<>


" not the lovely interaction plot from  the FAQ"



Which FAQ are you referring to?


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Kris Anderson
Gesendet: Montag, 17. August 2009 22:57
An: [email protected]
Betreff: st: Plotting 3way interactions

Hi,

I am struggling with a final line of code on plotting a 3way interaction 
in Stata. I can run everything except the two-way code for the scatter 
plot (I added ** to identify the line below). What I get is a mix of 
lines, not the lovely interaction plot from  the FAQ. Any suggestions?

regress avgdrink age sex gradedich white hisp csocanx caffil cpn SAF SP 
AP SAP if currentdrinker > 0
sum csocanx
global hi=r(max)
global lo=r(min)
sum caffil
global HAF=r(mean)+r(sd)
global LAF=r(mean)-r(sd)
sum cpn
global HPN=r(mean) +r(sd)
global LPN=r(mean) -r(sd)
sum age
global mage=r(mean)
sum gradedich
global mgrade=r(mean)
sum white
global mwhite=r(mean)
sum hisp
global mhisp=r(mean)
global HPNHAF "csocanx + ($HPN)*SP + ($HAF)*SAF + ($HPN)*($HAF)*SAP"
global HPNLAF "csocanx + ($HPN)*SP + ($LAF)*SAF + ($HPN)*($LAF)*SAP"
global LPNHAF "csocanx + ($LPN)*SP + ($HAF)*SAF + ($LPN)*($HAF)*SAP"
global LPNLAF "csocanx + ($LPN)*SP + ($LAF)*SAF + ($LPN)*($LAF)*SAP"
lincom $HPNHAF
global b1 = r(estimate)
lincom $HPNLAF
global b2 = r(estimate)
lincom $LPNHAF
global b3 = r(estimate)
lincom $LPNLAF
global b4 = r(estimate)
lincom _cons + $HPN*cpn + $HAF*caffil + $HPN*$HAF*AP + $mage*age + 
$mgrade*gradedich + $mwhite*white
global c1 = r(estimate)
lincom _cons + $HPN*cpn + $LAF*caffil + $HPN*$LAF*AP + $mage*age + 
$mgrade*gradedich + $mwhite*white
global c2 = r(estimate)
lincom _cons + $LPN*cpn + $HAF*caffil + $LPN*$HAF*AP + $mage*age + 
$mgrade*gradedich + $mwhite*white
global c3 = r(estimate)
lincom _cons + $LPN*cpn + $LAF*caffil + $LPN*$LAF*AP + $mage*age + 
$mgrade*gradedich + $mwhite*white
global c4 = r(estimate)
***twoway(function y=$c1+$b1*csocanx, range($lo $hi))(function 
y=$c2+$b2*csocanx, range($lo $hi))(function y=$c3+$b3*csocanx, range($lo 
$hi))(function y=$c4+$b4*csocanx, range($lo $hi))(scatter avgdrink cpn, 
msym(oh) jitter(3)), legend(order(1 "1 HPNHAF" 2 "2 HPNLAF" 3 "3 LAPHAF" 
4 "4 LAPLAF")) xtitle (X) ytitle(Y) name(con3wayb, replace)
lincom ($HPNHAF)- ($HPNLAF)
lincom ($HPNHAF)- ($LPNHAF)
lincom ($HPNLAF)- ($LPNLAF)
lincom ($LPNHAF)- ($LPNLAF)
lincom ($HPNHAF)- ($LPNLAF)
lincom ($HPNLAF)- ($LPNHAF)

Thank you.
*
*   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/


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index