infix age 1-3 fev 5-10 ht 12-15 str sex 19-24 str smoke 28-36 /// using "Z:\PUBLIC_web\Stat679\hw\fev.txt", clear drop in 1 drop in 655 generate male = sex=="Male" generate smoker = smoke=="Smoker" generate age15 = age - 15 summarize ht generate htc = ht - r(mean) regress fev age15 i.male##c.htc##c.htc i.smoker rvfplot margins male margins male, at(age15=0) margins male, at(age15=0 htc=0) margins male smoker marginsplot margins male smoker, at(age15=0 htc=0) marginsplot graph drop _all margins smoker, at(age15=(-12(1)4)) marginsplot, name(avgresponse) margins smoker, at(age15=(-12(1)4) htc=0) marginsplot, name(responseatavg) graph drop _all margins smoker, at(htc=(-12(1)4)) marginsplot, name(avgresponse) margins smoker, at(htc=(-12(1)4) age15=0) marginsplot, name(responseatavg) estimates table margins, dydx(age15) margins, dydx(htc) margins male, dydx(htc) at(age15=(-12(1)4)) marginsplot sort male smoker age egen h=mean(htc), by(male smoker age) by male smoker age: summ htc h sort male smoker htc egen a=mean(age15), by(male smoker htc) regress fev age15 i.male##c.htc##c.htc i.smoker predict fev1 preserve replace htc = h predict fev2 sort male smoker age by male smoker age: summ fev1 fev2 restore preserve replace age15 = a predict fev2 sort male smoker htc by male smoker htc: summ fev1 fev2 restore