Skip to content

Instantly share code, notes, and snippets.

@umran
Created March 31, 2018 19:47
Show Gist options
  • Save umran/7956ad158d91852bdf45cc46e3cf83dc to your computer and use it in GitHub Desktop.
Save umran/7956ad158d91852bdf45cc46e3cf83dc to your computer and use it in GitHub Desktop.
clear all
cd "~/irukandjilabs/econ490"
use "data/Women_complete_3states.dta"
gen children_ever_born = v201
gen done = 0
replace done = 1 if v605 == 5 | v605 == 6 | v605 == 7
recode done 0 = . if v605 == .
gen tfr = children_ever_born if done == 1
gen education_attainment = v149
gen education_years = v133
recode education_years 97 = .
gen knows_modern_contra = 0
recode knows_modern_contra 0 = 1 if v301 == 3
recode knows_modern_contra 0 = . if v301 == .
gen aware_std = 0
recode aware_std 0 = 1 if v750 == 1
recode aware_std 0 = . if v750 == 8
recode aware_std 0 = . if v750 == .
gen knows_condoms_reduce_aids_risk = 0
recode knows_condoms_reduce_aids_risk 0 = 1 if v754cp == 1
recode knows_condoms_reduce_aids_risk 0 = . if v754cp == 8
recode knows_condoms_reduce_aids_risk 0 = . if v754cp == .
gen always_aware_of_ovulatory = 0
recode always_aware_of_ovulatory 0 = 1 if v217 == 5
gen midcycle_aware_of_ovulatory = 0
recode midcycle_aware_of_ovulatory 0 = 1 if v217 == 3 | v217 == 5
recode midcycle_aware_of_ovulatory 0 = . if v217 == .
gen hug_aids = 0
recode hug_aids 0 = 1 if s907 == 0
recode hug_aids 0 = . if s907 == .
gen age = v012
gen urban = 0
recode urban 0 = 1 if v025 == 1
recode urban 0 = . if v025 == .
gen ideal_no_children = v613
recode ideal_no_children 96 = .
recode ideal_no_children 98 = .
gen could_get_condom = v769
recode could_get_condom 8 = .
gen wealth = v190
label variable wealth "wealth"
label define wealth 1 "poorest" 2 "poorer" 3 "middle" 4 "richer" 5 "richest"
label values wealth wealth
gen dead_children = v206 + v207
*NEW CODE
gen currently_preg = v213
gen birth_past_year = 0
recode birth_past_year 0 = 1 if v209 == 1 | v209 == 2
recode birth_past_year 0 = . if v209 == .
gen child_preg_recent = birth_past_year
recode child_preg_recent 0 = 1 if v213 == 1
recode child_preg_recent . = 1 if v213 == 1
recode child_preg_recent 0 = . if v213 == .
*this above is a test to make sure that ppl going to these lhs were not pregnant/recent child women.
*s356 = met in past 3 months with anm/lhv
gen met_anm_lhv = s356
gen education_collapsed = 0
recode education_collapsed 0 = 1 if education_attainment == 1 | education_attainment == 2
recode education_collapsed 0 = 2 if education_attainment == 3 | education_attainment == 4
recode education_collapsed 0 = 3 if education_attainment == 5
recode education_collapsed 0 = . if education_attainment == .
label define education_collapsed_labels 0 "none" 1 "primary" 2 "secondary" 3 "higher"
label values education_collapsed education_collapsed_labels
*v836=number of total partners of respondent
gen more_than_one = 0
recode more_than_one 0 = 1 if v836 == 2 | v836 == 3
recode more_than_one 0 = . if v836 == .
gen use_modern_method = 0
recode use_modern_method 0 = 1 if v302 == 3
recode use_modern_method 0 = . if v302 == .
*NEW CODE MARCH 24TH
* gen reason = 9
* recode reason 9=0 if s356==0
* recode reason 9=1 if s362b==1
* recode reason 9=2 if s362g==1
* recode reason 9=3 if s362h==1
* recode reason 9=4 if s362a==1
* recode reason 9=5 if s362c==1
* recode reason 9=6 if s362i==1
* recode reason 9=7 if s362p==1
* recode reason 9=8
* rename reason reason_to_meet_nurse
* label variable reason_to_meet_nurse "reason to meet nurse"
* label define reasona 0 "did not go" 1 "immunization" 2 "disease prevention" 3 "medical treatment for self" 4 "family planning" 5 "antenatal care" 6 "treatment for sick child" 7 "nutrition/health education" 8 "other"
* label values reason_to_meet_nurse reasona
* tab reason_to_meet_nurse
gen family_planning = s362a
* aids knowledge aggregation
gen aggre1 = 0
recode aggre1 0 = 1 if v754bp == 1
recode aggre1 0 = . if v754bp == .
gen aggre2 = 0
recode aggre2 0 = 1 if v754cp == 1
recode aggre2 0 = . if v754cp == .
gen aggre3 = 0
recode aggre3 0 = 1 if v754dp == 1
recode aggre3 0 = . if v754dp == .
gen aggre4 = 0
recode aggre4 0 = 1 if v754jp == 0
recode aggre4 0 = . if v754jp == .
gen aggre5 = 0
recode aggre5 0 = 1 if v754wp == 0
recode aggre5 0 = . if v754wp == .
gen aggre6 = 0
recode aggre6 0 = 1 if s907 == 0
recode aggre6 0 = . if s907 == .
gen agg_aids_aware = aggre1 + aggre2 + aggre3 + aggre4 + aggre5 + aggre6
gen recent_sex = 9
recode recent_sex 9 = 0 if v536 == 3 | v536 == 0
recode recent_sex 9 = 1 if v536 == 1
recode recent_sex 9 = . if v536 == 2
recode recent_sex 9 = . if v536 == .
gen religion_collapsed = 3
recode religion_collapsed 3 = 0 if v130 == 1
recode religion_collapsed 3 = 1 if v130 == 2
recode religion_collapsed 3 = 2 if v130 == 3
recode religion_collapsed 3 = . if v130 == .
label define religion_collapsed_labels 0 "hindu" 1 "muslim" 2 "christian" 3 "other"
label values religion_collapsed religion_collapsed_labels
// set state as the panel level
xtset v024
*finds that religion does effect the awareness of aids, thus is a potential confounding factor.
*dep var:
* tfr
*indep.var:
* i.reason_to_meet_nurse
* agg_aids_aware
* knows_modern_contra
* midcycle_aware_of_ovulatory
*controls
* i.education_attainment
* education_years
* i.wealth
* age
* urban
* -ideal_no_children
* dead_children
* i.religion_collapsed
* recent_sex
* use_modern_method
* birth_past_year
* currently_preg
*set of regressions for family planning
xtreg tfr family_planning
est sto FP_1
xtreg tfr family_planning i.education_collapsed
est sto FP_2
xtreg tfr family_planning i.education_collapsed education_years
est sto FP_3
xtreg tfr family_planning i.education_collapsed education_years i.wealth
est sto FP_4
xtreg tfr family_planning i.education_collapsed education_years i.wealth age urban dead_children i.religion_collapsed recent_sex
est sto FP_5
xtreg tfr family_planning i.education_collapsed education_years i.wealth age urban dead_children i.religion_collapsed recent_sex use_modern_method
est sto FP_6
xtreg tfr family_planning i.education_collapsed education_years i.wealth age urban dead_children i.religion_collapsed recent_sex use_modern_method birth_past_year currently_preg
est sto FP_7
esttab FP_1 FP_2 FP_3 FP_4 FP_5 FP_6 FP_7 using ~/irukandjilabs/econ490/results.docx, se aic obslast scalar(F) bic r2
* set of regressions for aids aware
xtreg tfr agg_aids_aware
est sto Aids_1
xtreg tfr agg_aids_aware i.education_collapsed
est sto Aids_2
xtreg tfr agg_aids_aware i.education_collapsed education_years
est sto Aids_3
xtreg tfr agg_aids_aware i.education_collapsed education_years i.wealth
est sto Aids_4
xtreg tfr agg_aids_aware i.education_collapsed education_years i.wealth age urban dead_children i.religion_collapsed recent_sex
est sto Aids_5
xtreg tfr agg_aids_aware i.education_collapsed education_years i.wealth age urban dead_children i.religion_collapsed recent_sex use_modern_method
est sto Aids_6
xtreg tfr agg_aids_aware i.education_collapsed education_years i.wealth age urban dead_children i.religion_collapsed recent_sex use_modern_method birth_past_year currently_preg
est sto Aids_7
esttab Aids_1 Aids_2 Aids_3 Aids_4 Aids_5 Aids_6 Aids_7
* set of regressions for know modern contra method
xtreg tfr knows_modern_contra
est sto modern_1
xtreg tfr knows_modern_contra i.education_collapsed
est sto modern_2
xtreg tfr knows_modern_contra i.education_collapsed education_years
est sto modern_3
xtreg tfr knows_modern_contra i.education_collapsed education_years i.wealth
est sto modern_4
xtreg tfr knows_modern_contra i.education_collapsed education_years i.wealth age urban dead_children i.religion_collapsed recent_sex
est sto modern_5
xtreg tfr knows_modern_contra i.education_collapsed education_years i.wealth age urban dead_children i.religion_collapsed recent_sex use_modern_method
est sto modern_6
xtreg tfr knows_modern_contra i.education_collapsed education_years i.wealth age urban dead_children i.religion_collapsed recent_sex use_modern_method birth_past_year currently_preg
est sto modern_7
esttab modern_1 modern_2 modern_3 modern_4 modern_5 modern_6 modern_7
* set of regressions for ovulatory cycle aware
xtreg tfr midcycle_aware_of_ovulatory
est sto ovu_1
xtreg tfr midcycle_aware_of_ovulatory i.education_collapsed
est sto ovu_2
xtreg tfr midcycle_aware_of_ovulatory i.education_collapsed education_years
est sto ovu_3
xtreg tfr midcycle_aware_of_ovulatory i.education_collapsed education_years i.wealth
est sto ovu_4
xtreg tfr midcycle_aware_of_ovulatory i.education_collapsed education_years i.wealth age urban dead_children i.religion_collapsed recent_sex
est sto ovu_5
xtreg tfr midcycle_aware_of_ovulatory i.education_collapsed education_years i.wealth age urban dead_children i.religion_collapsed recent_sex use_modern_method
est sto ovu_6
xtreg tfr midcycle_aware_of_ovulatory i.education_collapsed education_years i.wealth age urban dead_children i.religion_collapsed recent_sex use_modern_method birth_past_year currently_preg
est sto ovu_7
esttab ovu_1 ovu_2 ovu_3 ovu_4 ovu_5 ovu_6 ovu_7
*** Repeat The Same Regressions Using Ideal Number of Children as the Outcome ***
*set of regressions for family planning
xtreg ideal_no_children family_planning
est sto FP_1
xtreg ideal_no_children family_planning i.education_collapsed
est sto FP_2
xtreg ideal_no_children family_planning i.education_collapsed education_years
est sto FP_3
xtreg ideal_no_children family_planning i.education_collapsed education_years i.wealth
est sto FP_4
xtreg ideal_no_children family_planning i.education_collapsed education_years i.wealth age urban ideal_no_children dead_children i.religion_collapsed recent_sex
est sto FP_5
xtreg ideal_no_children family_planning i.education_collapsed education_years i.wealth age urban ideal_no_children dead_children i.religion_collapsed recent_sex use_modern_method
est sto FP_6
xtreg ideal_no_children family_planning i.education_collapsed education_years i.wealth age urban ideal_no_children dead_children i.religion_collapsed recent_sex use_modern_method birth_past_year currently_preg
est sto FP_7
esttab FP_1 FP_2 FP_3 FP_4 FP_5 FP_6 FP_7 using ~/irukandjilabs/econ490/results.docx, se aic obslast scalar(F) bic r2
* set of regressions for aids aware
xtreg ideal_no_children agg_aids_aware
est sto Aids_1
xtreg ideal_no_children agg_aids_aware i.education_collapsed
est sto Aids_2
xtreg ideal_no_children agg_aids_aware i.education_collapsed education_years
est sto Aids_3
xtreg ideal_no_children agg_aids_aware i.education_collapsed education_years i.wealth
est sto Aids_4
xtreg ideal_no_children agg_aids_aware i.education_collapsed education_years i.wealth age urban ideal_no_children dead_children i.religion_collapsed recent_sex
est sto Aids_5
xtreg ideal_no_children agg_aids_aware i.education_collapsed education_years i.wealth age urban ideal_no_children dead_children i.religion_collapsed recent_sex use_modern_method
est sto Aids_6
xtreg ideal_no_children agg_aids_aware i.education_collapsed education_years i.wealth age urban ideal_no_children dead_children i.religion_collapsed recent_sex use_modern_method birth_past_year currently_preg
est sto Aids_7
esttab Aids_1 Aids_2 Aids_3 Aids_4 Aids_5 Aids_6 Aids_7
* set of regressions for know modern contra method
xtreg ideal_no_children knows_modern_contra
est sto modern_1
xtreg ideal_no_children knows_modern_contra i.education_collapsed
est sto modern_2
xtreg ideal_no_children knows_modern_contra i.education_collapsed education_years
est sto modern_3
xtreg ideal_no_children knows_modern_contra i.education_collapsed education_years i.wealth
est sto modern_4
xtreg ideal_no_children knows_modern_contra i.education_collapsed education_years i.wealth age urban ideal_no_children dead_children i.religion_collapsed recent_sex
est sto modern_5
xtreg ideal_no_children knows_modern_contra i.education_collapsed education_years i.wealth age urban ideal_no_children dead_children i.religion_collapsed recent_sex use_modern_method
est sto modern_6
xtreg ideal_no_children knows_modern_contra i.education_collapsed education_years i.wealth age urban ideal_no_children dead_children i.religion_collapsed recent_sex use_modern_method birth_past_year currently_preg
est sto modern_7
esttab modern_1 modern_2 modern_3 modern_4 modern_5 modern_6 modern_7
* set of regressions for ovulatory cycle aware
xtreg ideal_no_children midcycle_aware_of_ovulatory
est sto ovu_1
xtreg ideal_no_children midcycle_aware_of_ovulatory i.education_collapsed
est sto ovu_2
xtreg ideal_no_children midcycle_aware_of_ovulatory i.education_collapsed education_years
est sto ovu_3
xtreg ideal_no_children midcycle_aware_of_ovulatory i.education_collapsed education_years i.wealth
est sto ovu_4
xtreg ideal_no_children midcycle_aware_of_ovulatory i.education_collapsed education_years i.wealth age urban ideal_no_children dead_children i.religion_collapsed recent_sex
est sto ovu_5
xtreg ideal_no_children midcycle_aware_of_ovulatory i.education_collapsed education_years i.wealth age urban ideal_no_children dead_children i.religion_collapsed recent_sex use_modern_method
est sto ovu_6
xtreg ideal_no_children midcycle_aware_of_ovulatory i.education_collapsed education_years i.wealth age urban ideal_no_children dead_children i.religion_collapsed recent_sex use_modern_method birth_past_year currently_preg
est sto ovu_7
esttab ovu_1 ovu_2 ovu_3 ovu_4 ovu_5 ovu_6 ovu_7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment