Statalist:
I am trying to do the following.
1. Take values of health, education, labor variables for a sample of men at age 20 and regress them on a health_index at age 30, save the betas.
2. Use these betas in a future equation to predict health at age 40.
My code is below along with a sample of my data. I think that I am saving the betas correctly using "predict, xbs" but I am not entirely sure. Also, idk how to find these betas and use them later for predicting health at age 40.....
Super thanks for any help on this.
I am trying to do the following.
1. Take values of health, education, labor variables for a sample of men at age 20 and regress them on a health_index at age 30, save the betas.
2. Use these betas in a future equation to predict health at age 40.
My code is below along with a sample of my data. I think that I am saving the betas correctly using "predict, xbs" but I am not entirely sure. Also, idk how to find these betas and use them later for predicting health at age 40.....
Super thanks for any help on this.
Code:
*step one: creating a variable for health and controls values at age 20 foreach v of varlist health_index lincomeb`k'_1 lincomeb`k'_2 fsize`k'_1 fsize`k'_2 fsize_incomeb`k' father_figure`k' male black bweight hgc02 hgcgrandmoth never_married married02 afqtmom lincomeb02 fsize02 southmom14 liveparents14 siblmom rural14 overweight accident illness health_work everproblem welfare unemployment foodstamps income posted employed financialstrain married_r economic_index college trade { gen `v'2=`v' if age==20 bys idc: egen `v'20=max(`v'2) bys idc: carryforward `v'20, replace } *step two: regress health_index at age 30+ with values at age 20, predict and save xbs local k = 4 local distb1 "distp_cutoff`k'" local d = 0.85 preserve keep if age>30 & all_male==1 reg health_index lincomeb`k'_120 lincomeb`k'_220 fsize`k'_120 fsize`k'_220 fsize_incomeb`k'20 father_figure`k'20 black20 bweight20 hgc0220 hgcgrandmoth20 never_married20 married0220 afqtmom20 lincomeb0220 fsize0220 southmom1420 liveparents1420 siblmom20 rural1420 overweight20 accident20 illness20 health_work20 everproblem20 welfare20 unemployment20 foodstamps20 income20 posted20 employed20 financialstrain20 married_r20 economic_index20 college20 trade20 predict predicthealth_30plus, xb
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(age health_index lincomeb4_120 married_r20) . . . . 33 .1513923 . . 29 .05537483 . . . . . . . . . . 35 -.4958639 . . . . . . . . . . . . . . 31 -.4118481 . . 17 .3456535 . . 13 -.4958639 . . 21 .3456535 . . 27 -.415097 . . 29 -.4958639 . . . . . . . . . . . . . . . . . . 13 -.4958639 . . 33 -.4958639 . . 31 -.4958639 . . . . . . 17 .7807171 . . 32 . . . . . . . . . . . 30 . . . 34 . . . . . . . 16 .6267617 . . . . . . 36 . . . . . . . . . . . 27 .7150816 . . . . . . 13 -.4958639 . . . . . . 17 -.3903777 . . 21 .7807171 . . . . . . 25 -.4008482 . . 23 .05537483 . . 18 -.3760564 10.46894 0 20 -.4008482 10.46894 0 16 .3456535 10.46894 0 12 -.4958639 10.46894 0 . . 10.46894 0 14 -.4958639 10.46894 0 . . . . . . . . 13 . . . . . . . 17 .2604401 . . . . . . . . . . 33 1.1192399 . . . . . . 39 2.0166187 . . . . . . 37 1.572919 . . 35 2.0166187 . . 21 .2604401 . . . . 9.122956 0 . . 9.122956 0 30 .08828463 9.122956 0 . . 9.122956 0 36 2.0166187 9.122956 0 34 .2184644 9.122956 0 32 2.0166187 9.122956 0 . . 9.122956 0 20 .2604401 9.122956 0 16 .2604401 9.122956 0 . . 9.122956 0 12 . 9.122956 0 . . 9.122956 0 . . 10.129276 0 16 .9948865 10.129276 0 12 2.0166187 10.129276 0 . . 10.129276 0 24 .8136269 10.129276 0 . . 10.129276 0 20 .45116645 10.129276 0 30 1.2172137 10.129276 0 28 .1012839 10.129276 0 26 .8136269 10.129276 0 . . 10.129276 0 21 -.388793 . . . . . . . . . . 17 -.388793 . . . . . . 13 -.4958639 . . 23 -.415097 . . 29 .2837221 . . 27 -.4008482 . . 25 -.415097 . . 21 .4837536 . . . . . . end
Comment