*Set directory to where the BlankWithId500.dta file is located: cd "C:\Documents and Settings\Administrator\My Documents\Teaching\581\Fall2008\classData\Simulated\" use "BlankWithId500.dta", clear gen x = rnormal(3,1) gen D = rbinomial(1, .6) *Select one of the following generation statements by moving the star from one *statement to the other. Feel free to alter the coefficients. gen y = 5 + 4*x + 2*D + 3*x*D + rnormal(0,3) *gen y = 5 + 4*x + 2*D + rnormal(0,3) gen xD=x*D label var xD "interaction term" *Notice that the correlation between the x and D variables are fine while *the correlation between x and xD or between D and xD are high. corr x D xD regress y x D regress y x D xD predict yhat0 if D==0 label var yhat0 "D=0" predict yhat1 if D==1 label var yhat1 "D=1" scatter y x || connected yhat0 x, lcolor(red) msymbol(i) || connected yhat1 x, lcolor(blue) msymbol(i)