Statalist


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

st: Plotting 3 way continuous interactions in regression


From   Kris Anderson <[email protected]>
To   [email protected]
Subject   st: Plotting 3 way continuous interactions in regression
Date   Wed, 12 Aug 2009 16:54:10 -0700

Hi,

I am stuck on a piece of code that I can't seem to debug. I am trying to 
plot a 3-way interaction using the FAQ on plotting these interactions 
with covariates. The code hangs up as I try to compute 4 simple slopes. 
The program tells me the name of my interaction term is invalid. Can 
anyone see a problem here? I tried renaming the variable but it didn't help.

Thanks

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 /* slope 1*/
global b1 = r(estimate)
lincom $HPNLAF /* slope 2*/
global b2 = r(estimate)
lincom $LPNHAF /* slope 3*/
global b3 = r(estimate)
lincom $LPNLAF /* slope 4*/
global b4 = r(estimate)





*
*   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