150 likes | 259 Views
CMGPD-LN Methodological variables. Day 9 Creation of variables for early-life study. Preceding birth interval. use "C:UsersCameron Campbe Documents Baqi CMGPD-LN from ICPSRICPSR_27063DS000127063-0001-Data.dta", clear
E N D
CMGPD-LNMethodological variables Day 9 Creation of variables for early-life study
Preceding birth interval use "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clear drop if MOTHER_ID == "-99" | BIRTHYEAR < 0 | (SEX == 1 & MARITAL_STATUS != 2) bysort PERSON_ID: keep if _n == 1 bysortMOTHER_ID (BIRTHYEAR): generate pbi = BIRTHYEAR - BIRTHYEAR[_n-1] bysortMOTHER_ID (BIRTHYEAR): generate firstborn = _n == 1 * Basically force firstborn and twin into separate categories represented by the dummy variables bysortMOTHER_ID (BIRTHYEAR): replace pbi = 0 if firstborn recode pbi 15/max=15 tab pbi keep PERSON_ID pbifirstborn save pbi
pbi | Freq. Percent Cum. ------------+----------------------------------- 0 | 76,026 51.57 51.57 1 | 4,385 2.97 54.54 2 | 10,152 6.89 61.43 3 | 9,843 6.68 68.11 4 | 7,615 5.17 73.27 5 | 6,238 4.23 77.50 6 | 5,478 3.72 81.22 7 | 4,339 2.94 84.16 8 | 3,569 2.42 86.58 9 | 3,138 2.13 88.71 10 | 2,669 1.81 90.52 11 | 2,063 1.40 91.92 12 | 1,945 1.32 93.24 13 | 1,456 0.99 94.23 14 | 1,292 0.88 95.11 15 | 7,215 4.89 100.00 ------------+----------------------------------- Total | 147,423 100.00
use "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clear merge m:1 PERSON_ID using pbi, keep(match master) keep if SEX == 2 bysort PERSON_ID (YEAR): keep if AGE_IN_SUI[1] > 0 & AGE_IN_SUI[1] <= 10 keep if AT_RISK_DIE == 1 & NEXT_3 == 1 & PRESENT == 1 generate short_pbi = firstborn == 0 & (pbi == 0 | pbi== 1 | pbi == 2) generate age_group= 1+5*int((AGE_IN_SUI-1)/5) xi:clogit NEXT_DIE i.age_group firstborn short_pbiif age_group >= 56 & age_group <= 75, group(MOTHER_ID)
. xi:clogit NEXT_DIE i.age_group firstborn short_pbi if age_group >= 56 & age_group <= 75, group(MOTHER_ID) i.age_group _Iage_group_1-166 (naturally coded; _Iage_group_1 omitted) note: multiple positive outcomes within groups encountered. note: 8860 groups (19131 obs) dropped because of all positive or all negative outcomes. Conditional (fixed-effects) logistic regression Number of obs = 9902 LR chi2(5) = 2041.71 Prob > chi2 = 0.0000 Log likelihood = -2389.4246 Pseudo R2 = 0.2993 ------------------------------------------------------------------------------ NEXT_DIE | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _Iage_gro~_6 | (omitted) … _Iage_gro~51 | (omitted) _Iage_gr~_56 | -4.255857 .1234024 -34.49 0.000 -4.497721 -4.013993 _Iage_gro~61 | -2.764736 .1071336 -25.81 0.000 -2.974714 -2.554758 _Iage_gr~_66 | -1.425874 .0934471 -15.26 0.000 -1.609027 -1.242721 _Iage_gro~71 | (omitted) … _Iage_gr~166 | (omitted) firstborn | -.2756034 .1105682 -2.49 0.013 -.4923131 -.0588938 short_pbi | .300082 .1539756 1.95 0.051 -.0017047 .6018687 ------------------------------------------------------------------------------
Age at which father last seen alive use "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clear merge 1:1 RECORD_NUMBER using "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0003\27063-0003-Data.dta" keep if SEX == 2 bysort PERSON_ID (YEAR): keep if AGE_IN_SUI[1] <= 10 & AGE_IN_SUI[1] >= 1 drop if FATHER_ALIVE < 0 drop if AGE_IN_SUI < 0 bysort PERSON_ID (FATHER_ALIVE YEAR): generate father_last_alive = AGE_IN_SUI[_N] bysort PERSON_ID (FATHER_ALIVE YEAR): replace father_last_alive = 0 if FATHER_ALIVE[_N] == 0 recode father_last_alive 1/5=1 6/10=6 11/15=11 16/max=16 generate ever_married = MARITAL_STATUS != 2 tab father_last_alive if SEX == 2 & AGE_IN_SUI >= 26 & AGE_IN_SUI <= 30, sum(ever_married) tab father_last_alive if SEX == 2 & AGE_IN_SUI >= 26 & AGE_IN_SUI <= 30 & HAS_POSITION >= 0, sum(HAS_POSITION)
. tab father_last_alive if SEX == 2 & AGE_IN_SUI >= 26 & AGE_IN_SUI <= 30, sum(ever_married) father_last | Summary of ever_married _alive | Mean Std. Dev. Freq. ------------+------------------------------------ 0 | .72305186 .4475514 3683 1 | .6979405 .45925601 2185 6 | .72417511 .44697719 4637 11 | .71541591 .45126712 4424 16 | .74787225 .43424031 35601 ------------+------------------------------------ Total | .73888779 .43924531 50530
. tab father_last_alive if SEX == 2 & AGE_IN_SUI >= 26 & AGE_IN_SUI <= 30 & HAS_POSITION >= 0, sum(HAS_POSITION) father_last | Summary of Has Official Position _alive | Mean Std. Dev. Freq. ------------+------------------------------------ 0 | .01466196 .12021194 3683 1 | .01464531 .12015586 2185 6 | .00841061 .09133275 4637 11 | .0187613 .13569627 4424 16 | .01949383 .1382547 35601 ------------+------------------------------------ Total | .01785078 .13241027 50530
Another approach to identifying age at last time father was observed use "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clear keep if SEX == 2 & PRESENT == 1 & AGE_IN_SUI > 0 bysortPERSON_ID (YEAR): keep if _n == _N keep PERSON_ID YEAR rename PERSON_ID FATHER_ID rename YEAR father_last_year save father_last_year, replace use "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clear keep if FATHER_ID != "-99" keep if SEX == 2 merge m:1 FATHER_ID using father_last_year, keep(match master) drop if father_last_year == . keep if BIRTHYEAR > 0 generate age_at_father_last_year = father_last_year - BIRTHYEAR recode age_at_father_last_year min/-11=-99 -10/0=0 1/5=1 6/10=6 11/15=11 16/max=16 tab age_at_father_last_year if HAS_POSITION >= 0 & AGE_IN_SUI >= 31 & AGE_IN_SUI <= 35, sum(HAS_POSITION) generate ever_married = MARITAL_STATUS != 2 tab age_at_father_last_year if MARITAL_STATUS >= 1 & AGE_IN_SUI >= 31 & AGE_IN_SUI <= 35, sum(ever_married)
. tab age_at_father_last_year age_at_fath | er_last_yea | r | Freq. Percent Cum. ------------+----------------------------------- -99 | 26,808 3.24 3.24 0 | 37,958 4.58 7.82 1 | 53,882 6.51 14.32 6 | 70,491 8.51 22.83 11 | 82,367 9.94 32.78 16 | 556,793 67.22 100.00 ------------+----------------------------------- Total | 828,299 100.00
. tab age_at_father_last_year if HAS_POSITION >= 0 & AGE_IN_SUI >= 31 & AGE_IN_SUI <= 35, sum(HAS_POSITION) age_at_fath | er_last_yea | Summary of Has Official Position r | Mean Std. Dev. Freq. ------------+------------------------------------ -99 | .01860465 .13520271 860 0 | .01583435 .12485973 2463 1 | .01697793 .12921048 2945 6 | .01438987 .11910299 5212 11 | .01950475 .13830241 5896 16 | .0251456 .15656902 43785 ------------+------------------------------------ Total | .022825 .14934653 61161
tab age_at_father_last_year if MARITAL_STATUS >= 1 & AGE_IN_SUI >= 31 & AGE_IN_SUI <= 35, sum(ever_married) age_at_fath | er_last_yea | Summary of ever_married r | Mean Std. Dev. Freq. ------------+------------------------------------ -99 | .80913349 .39321436 854 0 | .78486708 .41099859 2445 1 | .77785396 .41576007 2917 6 | .78262556 .41249944 5157 11 | .78500514 .41085395 5842 16 | .81671433 .38690501 43364 ------------+------------------------------------ Total | .80749104 .39427379 60579
Prices around time of birth use "C:\Users\Cameron Campbe\Documents\Baqi\prices\Annual logged low sorghum.dta" rename YEAR BIRTHYEAR sort BIRTHYEAR generate allosorg5 = allosorg[_n-2]+allosorg[_n-1]+allosorg+allosorg[_n+1]+allosorg[_n+2] save "Logged low sorghum prices around time of birthyear“ use "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clear merge m:1 BIRTHYEAR using "C:\Users\Cameron Campbe\Documents\Baqi\prices\Logged low sorghum prices around time of birthyear", keep(match master) generate age_group = 5*int((AGE_IN_SUI-1)/5)+1 keep if PRESENT == 1 & NEXT_3 == 1 & AT_RISK_DIE == 1 & AGE_IN_SUI >= 1 xi:logit NEXT_DIE i.age_group allosorg5 if SEX == 2 & AGE_IN_SUI >= 56 & AGE_IN_SUI <= 75 xi:logit NEXT_DIE i.age_group allosorg5 if SEX == 1 & AGE_IN_SUI >= 56 & AGE_IN_SUI <= 75
xi:logit NEXT_DIE i.age_group allosorg5 if SEX == 1 & AGE_IN_SUI >= 56 & AGE_IN_SUI <= 75 i.age_group _Iage_group_1-201 (naturally coded; _Iage_group_1 omitted) Iteration 0: log likelihood = -16182.212 Iteration 1: log likelihood = -15874.613 Iteration 2: log likelihood = -15864.592 Iteration 3: log likelihood = -15864.584 Iteration 4: log likelihood = -15864.584 Logistic regression Number of obs = 41779 LR chi2(4) = 635.26 Prob > chi2 = 0.0000 Log likelihood = -15864.584 Pseudo R2 = 0.0196 ------------------------------------------------------------------------------ NEXT_DIE | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _Iage_gro~_6 | (omitted) _Iage_gr~_51 | (omitted) _Iage_gr~_56 | -.9623698 .0432435 -22.25 0.000 -1.047125 -.8776141 _Iage_gr~_61 | -.6752047 .0438673 -15.39 0.000 -.761183 -.5892265 _Iage_gr~_66 | -.2201522 .0438849 -5.02 0.000 -.3061651 -.1341393 _Iage_gro~71 | (omitted) _Iage_gr~201 | (omitted) allosorg5 | -.0234833 .0087169 -2.69 0.007 -.0405681 -.0063984 _cons | -1.422218 .0437954 -32.47 0.000 -1.508055 -1.33638 ------------------------------------------------------------------------------ .
xi:logit NEXT_DIE i.age_group allosorg5 if SEX == 2 & AGE_IN_SUI >= 56 & AGE_IN_SUI <= 75 i.age_group _Iage_group_1-201 (naturally coded; _Iage_group_1 omitted) Iteration 0: log likelihood = -18151.951 Iteration 1: log likelihood = -17845.276 Iteration 2: log likelihood = -17836.418 Iteration 3: log likelihood = -17836.412 Iteration 4: log likelihood = -17836.412 Logistic regression Number of obs = 43633 LR chi2(4) = 631.08 Prob > chi2 = 0.0000 Log likelihood = -17836.412 Pseudo R2 = 0.0174 ------------------------------------------------------------------------------ NEXT_DIE | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _Iage_gr~_56 | -.9278634 .0410099 -22.63 0.000 -1.008241 -.8474854 _Iage_gr~_61 | -.6300167 .041833 -15.06 0.000 -.7120079 -.5480255 _Iage_gr~_66 | -.2499452 .0431567 -5.79 0.000 -.3345308 -.1653597 allosorg5 | -.0302716 .0082515 -3.67 0.000 -.0464442 -.0140989 _cons | -1.305654 .0422039 -30.94 0.000 -1.388373 -1.222936 ------------------------------------------------------------------------------