clear cap log close cap clear matrix set more off set mem 200m set matsize 800 program drop _all version 11.0 gl root "C:\DROPBOX\Dropbox\TESTS_COLOMBIA" gl testdata "$root\DATA\CLEANDATA\v4_tests\idb_portal\tests_bogota.dta" gl out "$root\DATA\CODE\v4_analysis_tests\idb_portal\descriptives" log using "$out/sample charact.log", replace use "$testdata" ********CHILD CHARACTERISTICS Variables******** *12-mth of age intervals gen m6t18=0 replace m6t18=1 if b_age_mth >= 5 & b_age_mth <= 18 gen m19t30=0 replace m19t30=1 if b_age_mth >= 19 & b_age_mth <= 30 gen m31t42=0 replace m31t42=1 if b_age_mth >= 31 & b_age_mth <= 42 *6-mth of age intervals gen m6t12=0 replace m6t12=1 if b_age_mth >= 5 & b_age_mth <= 12 gen m13t18=0 replace m13t18=1 if b_age_mth >= 13 & b_age_mth <= 18 gen m19t24=0 replace m19t24=1 if b_age_mth >= 19 & b_age_mth <= 24 gen m25t30=0 replace m25t30=1 if b_age_mth >= 25 & b_age_mth <= 30 gen m31t36=0 replace m31t36=1 if b_age_mth >= 31 & b_age_mth <= 36 gen m37t42=0 replace m37t42=1 if b_age_mth >= 37 & b_age_mth <= 42 ********PARENTAL CHARACTERISTICS Variables******** gen more_sec_ed_mo = 0 replace more_sec_ed_mo = 1 if edu_cat_mo > 3 replace more_sec_ed_mo =. if edu_cat_mo ==. gen more_sec_ed_fa = 0 replace more_sec_ed_fa = 1 if edu_cat_fa > 3 replace more_sec_ed_fa = . if edu_cat_fa ==. gen no_present_fa = 0 replace no_present_fa = 1 if dead_fa == 1 | absent_fa == 1 replace no_present_fa =. if dead_fa == . & absent_fa == . ********WEALTH DISTRIBUTION Variables********** gen quartil1 = 0 replace quartil1 = 1 if wealth_5p_qr == 1 gen quartil2 = 0 replace quartil2 = 1 if wealth_5p_qr == 2 gen quartil3 = 0 replace quartil3 = 1 if wealth_5p_qr == 3 gen quartil4 = 0 replace quartil4 = 1 if wealth_5p_qr == 4 gen estrato1 = 0 replace estrato1 = 1 if estrato == 1 gen estrato2 = 0 replace estrato2 = 1 if estrato == 2 gen estrato3 = 0 replace estrato3 = 1 if estrato == 3 gen estrato4 = 0 replace estrato4 = 1 if estrato == 4 ********FAMILY CARE INDEX Variables********** gen fci_books_news_score = fci_newspapers + fci_books_adults ********CHILD CHARACTERISTICS Labels******** label var m6t18 "6 to 18 months = 1" label var m19t30 "19 to 30 months = 1" label var m31t42 "31 to 42 months = 1" label var m6t12 "6 to 12 months = 1" label var m13t18 "13 to 18 months = 1" label var m19t24 "19 to 24 months = 1" label var m25t30 "25 to 30 months = 1" label var m31t36 "31 to 36 months = 1" label var m37t42 "37 to 42 months = 1" label var female "Female = 1" label var premature "Premature (gestional age <37 weeks) = 1" label var birthweight "Birth weight in gr." label var first_child "First born = 1" ********PARENTAL CHARACTERISTICS Labels******** label var age_mo "Age Mother" label var edu_mo "Education Years Mother" label var more_sec_ed_mo "Mother has more than Secondary Education = 1" label var work_mo "Mother Works (paid or unpaid) = 1" label var young_birth_mo "Mother Gave Birth Before Age 18 = 1" label var edu_fa "Education Years Father" label var more_sec_ed_fa "Father has more than Secondary Education = 1" label var no_present_fa "Father Deceased or No Longer Living with Child = 1" ********HOUSEHOLD CHARACTERISTICS Labels********** label var hhsize "Household Size" label var grandma_mo "Grandmother Lives in Houshold = 1" label var crowding "Crowding (people per room)" label var floors_quality "Quality Floors (tiles carpet wood) = 1" label var windows "External Windows = 1" label var kitchen_shared "Shared Kitchen = 1" label var bathroom_shared "Shared Bathroom = 1" label var bathroom_dnb "More than One Bathroom = 1" label var car "Car = 1" label var fridge "Fridge = 1" label var microwave "Microwave = 1" label var washer "Washing Machine = 1" label var boiler "Boiler = 1" label var computer "Computer = 1" label var smartphone "Smartphone = 1" label var flat_tv "Flat TV = 1" label var home_theatre "Home Theatre = 1" label var dvd "DVD = 1" label var stereo "Stereo = 1" label var consola "Games Console = 1" label var internet "Internet = 1" ********WEALTH DISTRIBUTION******* label var wealth_5p "Wealth Index" label var quartil1 "Quartil 1 = 1" label var quartil2 "Quartil 2 = 1" label var quartil3 "Quartil 3 = 1" label var quartil4 "Quartil 4 = 1" label var estrato1 "Estrato 1 = 1" label var estrato2 "Estrato 2 = 1" label var estrato3 "Estrato 3 = 1" label var estrato4 "Estrato 4 = 1" *******HOME STIMULATION Labels******** label var fci_books_news_score "Books and Newspapers (FCI Score)" label var fci_play_materials_1 "Play Materials (FCI Score)" label var fci_play_activities_1 "Play Activities (FCI Score)" *******CHILD CARE ARRENGMENTS Labels******** label var care_center "Child Care Center Attendance = 1" label var care_minder "Care Minder = 1" *******CATEGORIES************** local child_vars m6t18 m19t30 m31t42 m6t12 m13t18 m19t24 m25t30 m31t36 m37t42 female premature birthweight first_child stunted local par_vars age_mo edu_mo more_sec_ed_mo work_mo young_birth_mo edu_fa more_sec_ed_fa no_present_fa local hh_vars hhsize crowding grandma_mo floors_quality windows kitchen_shared bathroom_shared bathroom_dnb /// car fridge microwave washer boiler computer smartphone flat_tv home_theatre dvd stereo consola internet local fci_vars fci_books_news_score fci_play_materials_1 fci_play_activities_1 local care_vars care_center care_minder local wealth wealth_5p quartil1 quartil2 quartil3 quartil4 estrato1 estrato2 estrato3 estrato4 ********SUMMARIZE fo Bayley-III subsample!******** estpost summarize `child_vars' `par_vars' `hh_vars' `wealth' `fci_vars' `care_vars' /// if battery==2 // Battery A (ASQ3, Denver, MacArthur) est store A estpost summarize `child_vars' `par_vars' `hh_vars' `wealth' `fci_vars' `care_vars' /// if battery==1 // Battery B (Battelle, Adp. Behav., Milestones) est store B estpost summarize `child_vars' `par_vars' `hh_vars' `wealth' `fci_vars' `care_vars' est store C estpost ttest `child_vars' `par_vars' `hh_vars' `wealth' `fci_vars' `care_vars', by(battery) est store D ********EXPORT******** esttab C A B D using "$out\char_per_battery.csv", replace wide obslast plain /// title(Table 1: Mean Sample Characteristics by Battery) /// refcat(m6t18 "I. Child Characteristics" age_mo "II. Parental Characteristics" hhsize "III. Household Characteristics" /// wealth_5p "IV. Wealth Distribution" fci_books_news_score "V. Level Home Stimulation" care_center "VI. Child Care Arrangements", nolabel) /// collabel("N" "Mean" "SD" "Mean dif." "p-value") /// mtitle("Total" "Battery A" "Battery B" "Battery A - Battery B") /// cells ("count(fmt(3)) mean(fmt(3)) sd(fmt(3)) b(fmt(3)) p(fmt(3))") label lines nonum noobs /// addnote("Data are means. SD reported.") /// stats(N, fmt(%18.0g) labels("Observations")) ********** OBTAINING p-values of DIFFERENCES BY CLUSTERS (seccion) ********** #delimit; replace battery = 0 if battery == 2; gen varname = ""; gen meanall =.; gen sdall = .; gen obsall =.; gen obsbat0 =.; gen meanbat0 = . ; gen sdbat0 = . ; gen obstat1 = .; gen meanbat1 = .; gen sdbat1 = .; gen diffmean =.; gen pval =.; local j = 1; foreach var in `child_vars' {; replace varname="`var'" in `j' ; foreach y in 0 1 {; sum `var' if battery == `y'; replace meanbat`y' =r(mean) in `j'; replace sdbat`y' =r(sd) in `j'; scalar obstat`y' =r(N) in `j'; }; sum `var'; replace meanall =r(mean) in `j'; replace sdall =r(sd) in `j'; scalar obsall`y' =r(N) in `j'; reg `var' battery, cl(secc); replace diffmean = _b[battery] in `j'; local t = _b[battery]/_se[battery]; replace pval = 2*ttail(e(df_r),abs(`t')) in `j'; local j = `j'+1; }; local j = `j' + 1; foreach var in `par_vars' {; replace varname="`var'" in `j' ; foreach y in 0 1 {; sum `var' if battery == `y'; replace meanbat`y' =r(mean) in `j'; replace sdbat`y' =r(sd) in `j'; scalar obstat`y' =r(N) in `j'; }; sum `var'; replace meanall =r(mean) in `j'; replace sdall =r(sd) in `j'; scalar obsall`y' =r(N) in `j'; reg `var' battery, cl(secc); replace diffmean = _b[battery] in `j'; local t = _b[battery]/_se[battery]; replace pval = 2*ttail(e(df_r),abs(`t')) in `j'; local j = `j'+1; }; local j = `j' + 1; foreach var in `hh_vars' {; replace varname="`var'" in `j' ; foreach y in 0 1 {; sum `var' if battery == `y'; replace meanbat`y' =r(mean) in `j'; replace sdbat`y' =r(sd) in `j'; scalar obstat`y' =r(N) in `j'; }; sum `var'; replace meanall =r(mean) in `j'; replace sdall =r(sd) in `j'; scalar obsall`y' =r(N) in `j'; reg `var' battery, cl(secc); replace diffmean = _b[battery] in `j'; local t = _b[battery]/_se[battery]; replace pval = 2*ttail(e(df_r),abs(`t')) in `j'; local j = `j'+1; }; local j = `j' + 1; foreach var in `wealth' {; replace varname="`var'" in `j' ; foreach y in 0 1 {; sum `var' if battery == `y'; replace meanbat`y' =r(mean) in `j'; replace sdbat`y' =r(sd) in `j'; scalar obstat`y' =r(N) in `j'; }; sum `var'; replace meanall =r(mean) in `j'; replace sdall =r(sd) in `j'; scalar obsall`y' =r(N) in `j'; reg `var' battery, cl(secc); replace diffmean = _b[battery] in `j'; local t = _b[battery]/_se[battery]; replace pval = 2*ttail(e(df_r),abs(`t')) in `j'; local j = `j'+1; }; local j = `j' + 1; foreach var in `fci_vars' {; replace varname="`var'" in `j' ; foreach y in 0 1 {; sum `var' if battery == `y'; replace meanbat`y' =r(mean) in `j'; replace sdbat`y' =r(sd) in `j'; scalar obstat`y' =r(N) in `j'; }; sum `var'; replace meanall =r(mean) in `j'; replace sdall =r(sd) in `j'; scalar obsall`y' =r(N) in `j'; reg `var' battery, cl(secc); replace diffmean = _b[battery] in `j'; local t = _b[battery]/_se[battery]; replace pval = 2*ttail(e(df_r),abs(`t')) in `j'; local j = `j'+1; }; local j = `j' + 1; foreach var in `care_vars' {; replace varname="`var'" in `j' ; foreach y in 0 1 {; sum `var' if battery == `y'; replace meanbat`y' =r(mean) in `j'; replace sdbat`y' =r(sd) in `j'; scalar obstat`y' =r(N) in `j'; }; sum `var'; replace meanall =r(mean) in `j'; replace sdall =r(sd) in `j'; scalar obsall`y' =r(N) in `j'; reg `var' battery, cl(secc); replace diffmean = _b[battery] in `j'; local t = _b[battery]/_se[battery]; replace pval = 2*ttail(e(df_r),abs(`t')) in `j'; local j = `j'+1; }; local j = `j' + 1; keep varname meanall sdall meanbat0 sdbat0 meanbat1 sdbat1 diffmean pval; save "$out/sample charact_ttests.dta", replace; log close;