* To learn more about aweight * https://www.stata.com/support/faqs/statistics/analytical-weights-with-linear-regression/ u NHIS2009_clean, clear * Without aweight sort hi ttest hlth if fml==0, by(hi) * Question a * Comparison of husband health by health insurance outcome * Use summing and by hand with equal variances sum hlth if fml==0 & hi==1 [ w=perweight ] local N1 = r(N) local av1 = r(mean) local sd1 = r(sd) sum hlth if fml==0 & hi==0 [ w=perweight ] local N2 = r(N) local av2 = r(mean) local sd2 = r(sd) ttesti `N1' `av1' `sd1' `N2' `av2' `sd2' , level (95) * Use summing and by hand with unequal variances sum hlth if fml==0 & hi==1 [ w=perweight ] local N1 = r(N) local av1 = r(mean) local sd1 = r(sd) sum hlth if fml==0 & hi==0 [ w=perweight ] local N2 = r(N) local av2 = r(mean) local sd2 = r(sd) ttesti `N1' `av1' `sd1' `N2' `av2' `sd2' , unequal * Question b * i. are employed? * Use summing and by hand with equal variances sum hlth if fml==0 & hi==1 & empl==1 [ w=perweight ] local N1 = r(N) local av1 = r(mean) local sd1 = r(sd) sum hlth if fml==0 & hi==0 & empl==1 [ w=perweight ] local N2 = r(N) local av2 = r(mean) local sd2 = r(sd) ttesti `N1' `av1' `sd1' `N2' `av2' `sd2' , level (95) * ii. are employed and have at least 12 years of education? * Use summing and by hand with equal variances sum hlth if fml==0 & hi==1 & empl==1 & yedu>=12 [ w=perweight ] local N1 = r(N) local av1 = r(mean) local sd1 = r(sd) sum hlth if fml==0 & hi==0 & empl==1 & yedu>=12 [ w=perweight ] local N2 = r(N) local av2 = r(mean) local sd2 = r(sd) ttesti `N1' `av1' `sd1' `N2' `av2' `sd2' , level (95) * iii. are employed, have at least 12 years of education, and earn income of at least $80,000? sum hlth if fml==0 & hi==1 & empl==1 & yedu>=12 & inc>=80000 [ w=perweight ] local N1 = r(N) local av1 = r(mean) local sd1 = r(sd) sum hlth if fml==0 & hi==0 & empl==1 & yedu>=12 & inc>=80000 [ w=perweight ] local N2 = r(N) local av2 = r(mean) local sd2 = r(sd) ttesti `N1' `av1' `sd1' `N2' `av2' `sd2' , level (95) * Question c *by regression reg hlth hi if fml==0 [ w=perweight ], robust eststo m1 reg hlth hi age if fml==0 [ w=perweight ], robust eststo m2 reg hlth hi age yedu if fml==0 [ w=perweight ], robust eststo m3 reg hlth hi age yedu inc if fml==0 [ w=perweight ], robust eststo m4 #d; esttab m1 m2 m3 m4 using table1nhis.rtf, replace cells(b (star fmt(3)) se(par fmt(2))) varlabels(health "Health" hi "Health insurance" empl "Employed dummy" inc "Income" yedu "Years of Education" _cons "Constant") nomtitle title("Table 1") label stats(r2 N rmse, fmt(4 0 4) labels("R squared" "No. of obs." "Root Mean Square Error")) starlevels(* 0.10 ** 0.05 *** 0.01) collabels(none) stardetach legend note ("Robust standard errors in parenthesis.") ;