*********************************************************************************************************************** ** Human Development Report Office (HDRO), United Nations Development Programme ** Multidimensional Poverty Index 2021 release ** Methodology developed in partnership with the Oxford Poverty and Human Development Initiative, University of Oxford ************************************************************************************************************************ clear all set more off set maxvar 10000 set mem 500m cap log close *** Working Folder Path *** global path_in "C:\Users\cecilia.calderon\Documents\HDRO_MCC\MPI\MPI 2.0\Morocco 2017-18_PAPFAM\Bases" global path_out "C:\Users\cecilia.calderon\Documents\HDRO_MCC\MPI\MPI 2.0\Morocco 2017-18_PAPFAM\Bases" global path_logs "C:\Users\cecilia.calderon\Documents\HDRO_MCC\MPI\MPI 2.0\Morocco 2017-18_PAPFAM\Bases" global path_qc "C:\Users\cecilia.calderon\Documents\HDRO_MCC\MPI\MPI 2.0\Morocco 2017-18_PAPFAM\Bases" global path_ado "C:" *** Log file *** log using "$path_logs/Morocco_PAPFAM18_dataprep.log", replace ******************************************************************************** *** Morocco PAPFAM 2018 *** ******************************************************************************** ******************************************************************************** *** Step 1: Data preparation *** Selecting main variables from CH, WM, HH & MN recode & merging with HL recode ******************************************************************************** /* Morocco PAPFAM 2018: P4 indicates that anthropometric data was collected for all childen under 5 years. */ ******************************************************************************** *** Step 1.1 CH - CHILDREN's RECODE (under 5) ******************************************************************************** use "$path_in/Poids-taille.dta", clear rename _all, lower *** Generate individual unique key variable required for data merging *** hh1=cluster number; *** hh2=household number; *** ln=child's line number in household *gen ln=uf4 gen hh1 = district gen hh2 = hh_n gen ln = q501 replace ln=11 if district==717 & hh_n==3 & q501==10 & q504==4.2 gen double ind_id = hh1*100000 + hh2*100 + ln format ind_id %20.0g label var ind_id "Individual ID" duplicates report ind_id //1 error due to wrong line number, I will fix it looking at the HR dataset gen child_CH=1 //Generate identification variable for observations in CH recode /* For this part of the do-file we use the WHO Anthro and macros. This is to calculate the z-scores of children under 5. Source of ado file: http://www.who.int/childgrowth/software/en/ */ *** Next, indicate to STATA where the igrowup_restricted.ado file is stored: adopath + "C:\Users\cecilia.calderon\Documents\HDRO_MCC\MPI\WHO igrowup STATA\" *** We will now proceed to create three nutritional variables: *** weight-for-age (underweight), *** weight-for-height (wasting) *** height-for-age (stunting) /* We use 'reflib' to specify the package directory where the .dta files containing the WHO Child Growth Standards are stored. Note that we use strX to specify the length of the path in string. If the path is long, you may specify str55 or more, so it will run. */ gen str100 reflib="C:\igrowup_stata" lab var reflib "Directory of reference tables" /* We use datalib to specify the working directory where the input STATA dataset containing the anthropometric measurement is stored. */ gen str100 datalib = "$path_out" lab var datalib "Directory for datafiles" /* We use datalab to specify the name that will prefix the output files that will be produced from using this ado file (datalab_z_r_rc and datalab_prev_rc)*/ gen str30 datalab = "children_nutri_Morocco" lab var datalab "Working file" *** Next check the variables that WHO ado needs to calculate the z-scores: *** sex, age, weight, height, measurement, oedema & child sampling weight *** Variable: SEX *** tab q102, miss //Check the variable for "sex" has: "1" for male ;"2" for female tab q102, nol clonevar gender = q102 desc gender tab gender *** Variable: AGE *** gen mdate = ym(yy1, mm1) gen bdate = ym(annee, mois) //Calculate birth date from date of interview gen age_months = (mdate-bdate) //Calculate age in months replace age_months = 0 if age_months<0 gen str6 ageunit = "months" lab var ageunit "Months" *** Variable: BODY WEIGHT (KILOGRAMS) *** codebook q504, tab (9999) clonevar weight = q504 replace weight = . if q504>=99 tab resultat q504 if q504>=99 | q504==., miss //resultat: result of the measurement *tab uf9 if resultat==. & q504==. desc weight summ weight *** Variable: HEIGHT (CENTIMETERS) codebook q505, tab (9999) clonevar height = q505 replace height = . if q505>=999 tab resultat q505 if q505>=999 | q505==., miss desc height summ height *** Variable: MEASURED STANDING/LYING DOWN codebook q506 gen measure = "l" if q506==1 //Child measured lying down replace measure = "h" if q506==2 //Child measured standing up replace measure = " " if q506==9 | q506==0 | q506==. //Replace with " " if unknown desc measure tab measure *** Variable: OEDEMA *** lookfor oedema gen str1 oedema = "n" //It assumes no-one has oedema desc oedema tab oedema *** Variable: INDIVIDUAL CHILD SAMPLING WEIGHT *** gen sw = normalizedhhweight desc sw summ sw /*We now run the command to calculate the z-scores with the adofile */ igrowup_restricted reflib datalib datalab gender age_months ageunit weight height measure oedema sw /*We now turn to using the dta file that was created and that contains the calculated z-scores to create the child nutrition variables following WHO standards */ use "$path_out/children_nutri_Morocco_z_rc.dta", clear gen underweight = (_zwei < -2.0) replace underweight = . if _zwei == . | _fwei==1 lab var underweight "Child is undernourished (weight-for-age) 2sd - WHO" tab underweight, miss gen stunting = (_zlen < -2.0) replace stunting = . if _zlen == . | _flen==1 lab var stunting "Child is stunted (length/height-for-age) 2sd - WHO" tab stunting, miss gen wasting = (_zwfl < - 2.0) replace wasting = . if _zwfl == . | _fwfl == 1 lab var wasting "Child is wasted (weight-for-length/height) 2sd - WHO" tab wasting, miss count if _fwei==1 | _flen==1 /* Implausible values are excluded */ //Retain relevant variables: keep ind_id child_CH ln underweight stunting wasting order ind_id child_CH ln underweight stunting wasting sort ind_id duplicates report ind_id //Erase files from folder: erase "$path_out/children_nutri_Morocco_z_rc.xls" erase "$path_out/children_nutri_Morocco_prev_rc.xls" *erase "$path_out/children_nutri_Morocco_z_rc.dta" //Save a temp file for merging with HL: save "$path_out/Morocco18_CH.dta", replace ******************************************************************************** *** Step 1.2 BR - BIRTH RECODE *** (All females 15-49 years who ever gave birth) ******************************************************************************** /* The purpose of step 1.2 is to identify children of any age who died in the last 5 years prior to the survey date. */ use "$path_in/BH.dta", clear rename _all, lower gen hh1 = district gen hh2 = hh_n gen ln = wmn_n *** Generate individual unique key variable required for data merging using: *** hh1=cluster number; *** hh2=household number; *** wm4=women's line number. *codebook ln bhln, tab (100) /* Two non-identical variables exist instead of wm4 for women's line number, ln and bhln; We used ln, because it alligns with the HL dta file. */ gen double ind_id = hh1*100000 + hh2*100 + ln format ind_id %20.0g label var ind_id "Individual ID" gen bh4c = ym(w216_y, w216_m) gen bh9c = w221n if w221u==2 replace bh9c = w221n/30.4375 if w221u==1 replace bh9c = w221n*12 if w221u==3 gen wdoi = ym(w_yy, w_mm) sum wdoi bh4c bh9c gen date_death = bh4c + bh9c //Date of death = date of birth (bh4c) + age at death (bh9c) gen mdead_survey = wdoi-date_death //Months dead from survey = Date of interview (wdoi) - date of death replace mdead_survey = . if (bh9c==0 | bh9c==.) & w217==1 /*Replace children who are alive as '.' to distinguish them from children who died at 0 months */ gen ydead_survey = mdead_survey/12 //Years dead from survey codebook w217, tab (10) //w217 - Child still alive: 1=Yes; 2=No gen child_died = 1 if w217==2 //1=child dead; 0=child alive replace child_died = 0 if w217==1 replace child_died = . if w217==. label define lab_died 0"child is alive" 1"child has died" label values child_died lab_died tab w217 child_died, miss replace child_died=0 if bh9c>=216 & bh9c<. bysort ind_id: egen tot_child_died = sum(child_died) //For each woman, sum the number of children who died bysort ind_id: egen tot_child_died_5y=sum(child_died) if ydead_survey<=5 /*For each woman, sum the number of children who died in the past 5 years prior to the interview date */ replace tot_child_died_5y=0 if tot_child_died_5y==. & tot_child_died>=0 & tot_child_died<. /*All children who are alive and died longer than 5 years from the interview date are replaced as '0'*/ replace tot_child_died_5y=. if child_died==1 & ydead_survey==. //Replace as '.' if there is no information on when the child died tab tot_child_died tot_child_died_5y, miss bysort ind_id: egen child_died_per_wom = max(tot_child_died) lab var child_died_per_wom "Total child death for each women (birth recode)" bysort ind_id: egen child_died_per_wom_5y = max(tot_child_died_5y) lab var child_died_per_wom_5y "Total child death for each women in the last 5 years (birth recode)" //Keep one observation per women bysort ind_id: gen id=1 if _n==1 keep if id==1 drop id duplicates report ind_id gen women_BH = 1 //Identification variable for observations in BH recode //Retain relevant variables keep ind_id hh1 hh2 women_BH child_died_per_wom child_died_per_wom_5y order ind_id hh1 hh2 women_BH child_died_per_wom child_died_per_wom_5y sort ind_id //Save a temp file for merging with HL: save "$path_out/Morocco18_BH.dta", replace ******************************************************************************** *** Step 1.2 WM - WOMEN's RECODE *** (All eligible females 15-49 years in the household) ******************************************************************************** ** NEVER MARRIED WOMEN WERE NOT INTERVIEWED FOR FERTILITY AND MORTALITY, THEY WILL BE ASSUMED TO BE NOT DEPRIVED IN CHILD MORTALITY ** use "$path_in/WOM.dta", clear rename _all, lower gen hh1 = district gen hh2 = hh_n gen ln = wmn_n *** Generate individual unique key variable required for data merging *** hh1=cluster number; *** hh2=household number; *** ln=respondent's line number *gen ln=wm4 gen double ind_id = hh1*100000 + hh2*100 + ln format ind_id %20.0g label var ind_id "Individual ID" duplicates report ind_id gen women_WM =1 //Identification variable for observations in WM recode tab w103, miss /* age of woman */ tab w201 w206, miss /*Women who has never ever given birth will not have information on child mortality */ lookfor marital codebook w118, tab (10) tab w118, miss gen marital = 1 if w118 == 5 //1: Never married replace marital = 2 if w118 == 1 //2: Currently married replace marital = 3 if w118 == 2 //3: Widowed replace marital = 4 if w118 == 3 //4: Divorced replace marital = 5 if w118 == 4 //5: Separated/not living together label define lab_mar 1"never married" 2"currently married" 3"widowed" 4"divorced" 5"not living together" label values marital lab_mar label var marital "Marital status of household member" tab w118 marital, miss //Retain relevant variables: keep resultat w201 w206 w207_1 w207_2 ind_id women_WM marital order resultat w201 w206 w207_1 w207_2 ind_id women_WM marital sort ind_id //Save a temp file for merging with HL: save "$path_out/Morocco18_WM.dta", replace ******************************************************************************** *** Step 1.3 MN - MEN'S RECODE ***(All eligible man: 15-49 years in the household) ******************************************************************************** ** NO MEN DATASET ** /*use "$path_in/mn.dta", clear rename _all, lower *** Generate individual unique key variable required for data merging *** hh1=cluster number; *** hh2=household number; *** ln=respondent's line number gen double ind_id = hh1*100000 + hh2*100 + ln format ind_id %20.0g label var ind_id "Individual ID" duplicates report ind_id gen men_MN=1 //Identification variable for observations in MR recode lookfor marital codebook mmstatus mma6, tab (10) tab mmstatus mma6, miss gen marital = 1 if mmstatus == 3 & mma6==. //1: Never married replace marital = 2 if mmstatus == 1 & mma6==. //2: Currently married replace marital = 3 if mmstatus == 2 & mma6==1 //3: Widowed replace marital = 4 if mmstatus == 2 & mma6==2 //4: Divorced replace marital = 5 if mmstatus == 2 & mma6==3 //5: Separated/not living together label define lab_mar 1"never married" 2"currently married" 3"widowed" /// 4"divorced" 5"not living together" label values marital lab_mar label var marital "Marital status of household member" tab marital, miss tab mma6 marital, miss tab mmstatus marital, miss //Retain relevant variables: keep mcm1 mcm8 mcm9 mcm10 ind_id men_MN marital order mcm1 mcm8 mcm9 mcm10 ind_id men_MN marital sort ind_id //Save a temp file for merging with HL: save "$path_out/Morocco18_MN.dta", replace*/ ******************************************************************************** *** Step 1.4 HH - HOUSEHOLD RECODE ***(All households interviewed) ******************************************************************************** use "$path_in/HH.dta", clear rename _all, lower gen hh1 = district gen hh2 = hh_n *** Generate individual unique key variable required for data merging *** hh1=cluster number; *** hh2=household number; gen double hh_id = hh1*100 + hh2 format hh_id %20.0g lab var hh_id "Household ID" duplicates report hh_id //Save a temp file for merging with HL: save "$path_out/Morocco18_HH.dta", replace ******************************************************************************** *** Step 1.5 HL - HOUSEHOLD MEMBER ******************************************************************************** use "$path_in/HR.dta", clear rename _all, lower gen year = "2017-2018" gen survey = "PAPFAM" gen country = "Morocco" gen countrycode = "MAR" gen hh1 = district gen hh2 = hh_n gen ln = q100 *** Generate a household unique key variable at the household level using: ***hh1=cluster number ***hh2=household number gen double hh_id = hh1*100 + hh2 format hh_id %20.0g label var hh_id "Household ID" *** Generate individual unique key variable required for data merging using: *** hh1=cluster number; *** hh2=household number; *** hl1=respondent's line number. gen double ind_id = hh1*100000 + hh2*100 + ln format ind_id %20.0g label var ind_id "Individual ID" duplicates report ind_id sort ind_id ******************************************************************************** *** Step 1.6 DATA MERGING ******************************************************************************** *** Merging BR Recode ***************************************** merge 1:1 ind_id using "$path_out/Morocco18_BH.dta" drop if _merge==2 /* 7 obs */ drop _merge erase "$path_out/Morocco18_BH.dta" *** Merging WM Recode ***************************************** merge 1:1 ind_id using "$path_out/Morocco18_WM.dta" drop if _merge==2 /* 13 obs */ tab q107, miss gen temp = (q107<.) tab women_WM temp, miss col tab resultat if temp==1 & women_WM==., miss //Total of eligible women not interviewed drop temp drop _merge erase "$path_out/Morocco18_WM.dta" *** Merging HH Recode ***************************************** merge m:1 hh_id using "$path_out/Morocco18_HH.dta" drop if _merge==2 //Drop households that were not interviewed drop _merge erase "$path_out/Morocco18_HH.dta" *** Merging MN Recode ***************************************** *merge 1:1 ind_id using "$path_out/Morocco18_MN.dta" *drop _merge *erase "$path_out/Morocco18_MN.dta" *** Merging CH Recode ***************************************** merge 1:1 ind_id using "$path_out/Morocco18_CH.dta" drop if _merge==2 drop _merge erase "$path_out/Morocco18_CH.dta" sort ind_id ******************************************************************************** *** Step 1.7 CONTROL VARIABLES ******************************************************************************** /* Households are identified as having 'no eligible' members if there are no applicable population, that is, children 0-5 years, adult women 15-49 years or men 15-49 years. These households will not have information on relevant indicators of health. As such, these households are considered as non-deprived in those relevant indicators.*/ *** No Eligible Women 15-49 years ***************************************** gen fem_eligible = (q107<.) if q107!=. bys hh_id: egen hh_n_fem_eligible = sum(fem_eligible) //Number of eligible women for interview in the hh gen no_fem_eligible = (hh_n_fem_eligible==0) //Takes value 1 if the household had no eligible females for an interview lab var no_fem_eligible "Household has no eligible women" tab no_fem_eligible, miss ** never married women 15-49y are considered ineligible because they were not interviewed *** No Eligible Men 15-49 years ***************************************** *gen male_eligible = (hl9>0) if hl9!=. *bys hh_id: egen hh_n_male_eligible = sum(male_eligible) //Number of eligible men for interview in the hh *gen no_male_eligible = (hh_n_male_eligible==0) //Takes value 1 if the household had no eligible males for an interview *lab var no_male_eligible "Household has no eligible men" *tab no_male_eligible, miss *** No Eligible Children 0-5 years ***************************************** gen child_eligible = ((q108<. & q105<5) | child_CH==1) bys hh_id: egen hh_n_children_eligible = sum(child_eligible) //Number of eligible children for anthropometrics gen no_child_eligible = (hh_n_children_eligible==0) //Takes value 1 if there were no eligible children for anthropometrics lab var no_child_eligible "Household has no children eligible" tab no_child_eligible, miss *** No Eligible Women and Men *********************************************** gen no_adults_eligible = (no_fem_eligible==1) //Takes value 1 if the household had no eligible men & women for an interview lab var no_adults_eligible "Household has no eligible women" tab no_adults_eligible, miss *** No Eligible Children and Women *********************************************** /*NOTE: In the DHS datasets, we use this variable as a control variable for the nutrition indicator if nutrition data is present for children and women. However, in PAPFAM, we do NOT use this as a control variable. This is because nutrition data is only collected from children. However, we continue to generate this variable in this do-file so as to be consistent*/ gen no_child_fem_eligible = (no_child_eligible==1 & no_fem_eligible==1) lab var no_child_fem_eligible "Household has no children or women eligible" tab no_child_fem_eligible, miss *** No Eligible Women, Men or Children *********************************************** /*NOTE: In the DHS datasets, we use this variable as a control variable for the nutrition indicator if nutrition data is present for children, women and men. However, in PAPFAM, we do NOT use this as a control variable. This is because nutrition data is only collected from children. However, we continue to generate this variable in this do-file so as to be consistent*/ gen no_eligibles = (no_fem_eligible==1 & no_child_eligible==1) lab var no_eligibles "Household has no eligible women, men, or children" tab no_eligibles, miss *** No Eligible Subsample ***************************************** /*Note that the PAPFAM surveys do not collect hemoglobin data. As such, this variable takes missing value. However, we continue to generate this variable in this do-file so as to be consistent*/ gen hem_eligible =. bys hh_id: egen hh_n_hem_eligible = sum(hem_eligible) gen no_hem_eligible = (hh_n_hem_eligible==0) lab var no_hem_eligible "Household has no eligible individuals for hemoglobin measurements" drop fem_eligible hh_n_fem_eligible child_eligible hh_n_children_eligible hem_eligible hh_n_hem_eligible sort hh_id ******************************************************************************** *** Step 1.8 RENAMING DEMOGRAPHIC VARIABLES *** ******************************************************************************** //Sample weight clonevar weight = weighthh label var weight "Sample weight" //Area: urban or rural desc milieu clonevar area = milieu replace area=0 if area==2 label define lab_area 1 "urban" 0 "rural" label values area lab_area label var area "Area: urban-rural" //Relationship to the head of household desc q103 clonevar relationship = q103 codebook relationship, tab (20) recode relationship (1=1)(2=2)(3=3)(13=3)(4/12=4)(14=6)(15=5)(96=5)(97/98=.) /*Please ensure recoding follows these 6 broad categories: 1"head" 2"spouse" 3"child" 4"extended family" 5"not related" 6"maid" */ label define lab_rel 1"head" 2"spouse" 3"child" 4"extended family" 5"not related" 6"maid" label values relationship lab_rel label var relationship "Relationship to the head of household" tab q103 relationship, miss //Sex of household member codebook q102 clonevar sex = q102 label var sex "Sex of household member" //Age of household member codebook q105, tab (100) clonevar age = q105 *replace age = . if age>=98 label var age "Age of household member" //Age group recode age (0/4 = 1 "0-4")(5/9 = 2 "5-9")(10/14 = 3 "10-14") /// (15/17 = 4 "15-17")(18/59 = 5 "18-59")(60/max=6 "60+"), gen(agec7) lab var agec7 "age groups (7 groups)" recode age (0/9 = 1 "0-9") (10/17 = 2 "10-17")(18/59 = 3 "18-59") /// (60/max=4 "60+"), gen(agec4) lab var agec4 "age groups (4 groups)" //Total number of de jure hh members in the household gen member = 1 bysort hh_id: egen hhsize = sum(member) label var hhsize "Household size" tab hhsize, miss compare hhsize hh_member drop member //Subnational region * hh7a is at the district level lookfor region *lookfor state *codebook hh7, tab (100) *decode hh7, gen(temp) *replace temp = proper(temp) *encode temp, gen(region) lab var region "Region for subnational decomposition" *tab hh7 region, miss *drop temp ******************************************************************************** *** Step 2 Data preparation *** *** Standardization of the 10 Global MPI indicators *** Identification of non-deprived & deprived individuals ******************************************************************************** ******************************************************************************** *** Step 2.1 Years of Schooling *** ******************************************************************************** ** official school entrance age: 6 yrs ** official duration of primary school: 6 yrs tab q113 q112, miss codebook q113 q112 q111, tab (30) gen eduyears=1 if q113==1 & q112==1 replace eduyears=2 if q113==2 & q112==1 replace eduyears=3 if q113==3 & q112==1 replace eduyears=4 if q113==4 & q112==1 replace eduyears=5 if q113==5 & q112==1 replace eduyears=6 if (q113==6 | q113==7 | q113==11) & q112==1 replace eduyears=6 if q113==0 & q112==2 replace eduyears=7 if q113==1 & q112==2 replace eduyears=8 if q113==2 & q112==2 replace eduyears=9 if q113==3 & q112==2 replace eduyears=10 if (q113>=4 & q113<=8) & q112==2 replace eduyears=9 if q113==0 & q112==3 replace eduyears=10 if q113==1 & q112==3 replace eduyears=11 if q113==2 & q112==3 replace eduyears=12 if (q113>=3 & q113<=6) & q112==3 replace eduyears=12 if q113==0 & q112==4 replace eduyears=13 if q113==1 & q112==4 replace eduyears=14 if q113==2 & q112==4 replace eduyears=15 if q113==3 & q112==4 replace eduyears=16 if q113==4 & q112==4 replace eduyears=17 if (q113>=5 & q113<=24) & q112==4 replace eduyears=0 if q112==0 | q111==3 | (q113==0 & q112==1) lab var eduyears "Highest year of education completed" replace eduyears=6 if (q112>=2 & q112<=6) & (q113==98 | q113==99 | q113==.) ** imputing 6 years, we do not know how many years they completed but they completed 6 at least so for MPI they are not deprived tab eduyears q112, miss *** Cleaning inconsistencies replace eduyears = . if age<=eduyears & age>0 /*There are cases in which the years of schooling are greater than the age of the individual. This is clearly a mistake in the data. Please check whether this is the case and correct when necessary */ replace eduyears = 0 if age < 10 /*The variable "eduyears" was replaced with a '0' given that the criteria for this indicator is household member aged 10 years or older */ replace eduyears = 0 if (age==10 | age==11) & eduyears < 6 /*The variable "eduyears" was replaced with a '0' given that the criteria for this indicator is household member aged 12 years or older */ /*A control variable is created on whether there is information on years of education for at least 2/3 of the household members. */ gen temp = 1 if (eduyears!=. & (age>=12 & age!=.)) | (((age==10 | age==11) & eduyears>=6 & eduyears<.)) bysort hh_id: egen no_missing_edu = sum(temp) /*Total household members who are 12 years and older with no missing years of education but recognizing as an achievement if the member is 10 or 11 and already completed 6 yrs of schooling */ gen temp2 = 1 if (age>=12 & age!=.) | (((age==10 | age==11) & eduyears>=6 & eduyears<.)) bysort hh_id: egen hhs = sum(temp2) //Total number of household members who are 12 years and older replace no_missing_edu = no_missing_edu/hhs replace no_missing_edu = (no_missing_edu>=2/3) /*Identify whether there is information on years of education for at least 2/3 of the household members aged 12 years and older */ tab no_missing_edu, miss label var no_missing_edu "No missing edu for at least 2/3 of the HH members aged 12 years & older" drop temp temp2 hhs /*The entire household is considered deprived if no household member aged 12 years or older has completed SIX years of schooling. */ gen years_edu6 = (eduyears>=6) /* The years of schooling indicator takes a value of "1" if at least someone in the hh has reported 6 years of education or more */ replace years_edu6 = . if eduyears==. bysort hh_id: egen hh_years_edu6_1 = max(years_edu6) gen hh_years_edu6 = (hh_years_edu6_1==1) replace hh_years_edu6 = . if hh_years_edu6_1==. replace hh_years_edu6 = . if hh_years_edu6==0 & no_missing_edu==0 lab var hh_years_edu6 "Household has at least one member with 6 years of edu" ******************************************************************************** *** Step 2.2 Child School Attendance *** ******************************************************************************** codebook q111, tab (10) gen attendance = 1 if q111==1 //Replace attendance with '1' if currently attending school replace attendance = 0 if q111==2 | q111==3 //Replace attendance with '0' if currently not attending school *replace attendance = 0 if q111==3 //Replace attendance with '0' if never ever attended school *replace attendance = 0 if q111==1 & q112==4 //Replace attendance with '0' if attended school but informal schooling //informal education is not a category in Morocco tab age q111, miss //Check individuals who are not of school age replace attendance = 0 if age<5 | age>24 //Replace attendance with '0' for individuals who are not of school age tab attendance, miss label define lab_attend 1 "currently attending" 0 "not currently attending" label values attendance lab_attend label var attendance "Attended school during current school year" /*The entire household is considered deprived if any school-aged child is not attending school up to class 8. */ gen child_schoolage = (age>=6 & age<=14) /* Note: In Morocco, the official school entrance age is 6 years. So, age range is 6-14 (=6+8). Source: "http://data.uis.unesco.org/?ReportId=163" Go to Education>Education>System>Official entrance age to primary education. Look at the starting age and add 8. */ /*A control variable is created on whether there is no information on school attendance for at least 2/3 of the school age children */ count if child_schoolage==1 & attendance==. //Understand how many eligible school aged children are not attending school gen temp = 1 if child_schoolage==1 & attendance!=. bysort hh_id: egen no_missing_atten = sum(temp) /*Total school age children with no missing information on school attendance */ gen temp2 = 1 if child_schoolage==1 bysort hh_id: egen hhs = sum(temp2) //Total number of household members who are of school age replace no_missing_atten = no_missing_atten/hhs replace no_missing_atten = (no_missing_atten>=2/3) /*Identify whether there is missing information on school attendance for more than 2/3 of the school age children */ tab no_missing_atten, miss label var no_missing_atten "No missing school attendance for at least 2/3 of the school aged children" drop temp temp2 hhs bysort hh_id: egen hh_children_schoolage = sum(child_schoolage) replace hh_children_schoolage = (hh_children_schoolage>0) //Control variable: //It takes value 1 if the household has children in school age lab var hh_children_schoolage "Household has children in school age" gen child_not_atten = (attendance==0) if child_schoolage==1 replace child_not_atten = . if attendance==. & child_schoolage==1 bysort hh_id: egen any_child_not_atten = max(child_not_atten) gen hh_child_atten = (any_child_not_atten==0) replace hh_child_atten = . if any_child_not_atten==. replace hh_child_atten = 1 if hh_children_schoolage==0 replace hh_child_atten = . if hh_child_atten==1 & no_missing_atten==0 /*If the household has been intially identified as non-deprived, but has missing school attendance for at least 2/3 of the school aged children, then we replace this household with a value of '.' because there is insufficient information to conclusively conclude that the household is not deprived */ lab var hh_child_atten "Household has all school age children up to class 8 in school" tab hh_child_atten, miss /*Note: The indicator takes value 1 if ALL children in school age are attending school and 0 if there is at least one child not attending. Households with no children receive a value of 1 as non-deprived. The indicator has a missing value only when there are all missing values on children attendance in households that have children in school age. */ ******************************************************************************** *** Step 2.3 Nutrition *** ******************************************************************************** ******************************************************************************** *** Step 2.3a Child Nutrition *** ******************************************************************************** *** Child Underweight Indicator *** ************************************************************************ bysort hh_id: egen temp = max(underweight) gen hh_no_underweight = (temp==0) //Takes value 1 if no child in the hh is underweight replace hh_no_underweight = . if temp==. replace hh_no_underweight = 1 if no_child_eligible==1 //Households with no eligible children will receive a value of 1 lab var hh_no_underweight "Household has no child underweight - 2 stdev" drop temp *** Child Stunting Indicator *** ************************************************************************ bysort hh_id: egen temp = max(stunting) gen hh_no_stunting = (temp==0) //Takes value 1 if no child in the hh is stunted replace hh_no_stunting = . if temp==. replace hh_no_stunting = 1 if no_child_eligible==1 lab var hh_no_stunting "Household has no child stunted - 2 stdev" drop temp *** Child Either Stunted or Underweight Indicator *** ************************************************************************ gen uw_st = 1 if stunting==1 | underweight==1 replace uw_st = 0 if stunting==0 & underweight==0 replace uw_st = . if stunting==. & underweight==. bysort hh_id: egen temp = max(uw_st) gen hh_no_uw_st = (temp==0) //Takes value 1 if no child in the hh is underweight or stunted replace hh_no_uw_st = . if temp==. replace hh_no_uw_st = 1 if no_child_eligible==1 //Households with no eligible children will receive a value of 1 lab var hh_no_uw_st "Household has no child underweight or stunted" drop temp ******************************************************************************** *** Step 2.3b Household Nutrition Indicator *** ******************************************************************************** /* The indicator takes value 1 if there is no children under 5 underweight or stunted. It also takes value 1 for the households that have no eligible children. The indicator takes value missing "." only if all eligible children have missing information in their respective nutrition variable. */ ************************************************************************ gen hh_nutrition_uw_st = hh_no_uw_st lab var hh_nutrition_uw_st "Household has no child underweight or stunted" ******************************************************************************** *** Step 2.4 Child Mortality *** ******************************************************************************** codebook w207_1 w207_2 //cm9 or mcm9: number of sons who have died //cm10 or mcm10: number of daughters who have died replace w201=1 if w206==1 & w201==2 /* NEW */ ** the line above may not apply to other countries, check that in fact some children died dispete the inconsistency with the data ** egen temp_f = rowtotal(w207_1 w207_2), missing //Total child mortality reported by eligible women replace temp_f = 0 if (w201==1 & w206==2) | w201==2 /*Assign a value of "0" for: - all eligible women who have ever gave birth but reported no child death - all eligible women who never ever gave birth */ *replace temp_f = 0 if no_fem_eligible==1 /* NEW */ /*Assign a value of "0" for: - individuals living in households that have non-eligible women */ bysort hh_id: egen child_mortality_f = sum(temp_f), missing lab var child_mortality_f "Occurrence of child mortality reported by women" tab child_mortality_f, miss drop temp_f /*replace mcm1=1 if mcm8==1 & mcm1==2 /* NEW */ ** the line above is not always necessary, it depends on cmc9 and cmc10 egen temp_m = rowtotal(mcm9 mcm10), missing //Total child mortality reported by eligible men replace temp_m = 0 if (mcm1==1 & mcm8==2) | mcm1==2 /*Assign a value of "0" for: - all eligible men who ever fathered children but reported no child death - all eligible men who never fathered children */ *replace temp_m = 0 if no_male_eligible==1 /* NEW */ /*Assign a value of "0" for: - individuals living in households that have non-eligible men */ bysort hh_id: egen child_mortality_m = sum(temp_m), missing lab var child_mortality_m "Occurrence of child mortality reported by men" tab child_mortality_m, miss drop temp_m*/ egen child_mortality = rowmax(child_mortality_f) lab var child_mortality "Total child mortality within household reported by women" tab child_mortality, miss replace child_mortality=0 if no_fem_eligible==1 gen hh_mortality = (child_mortality==0) replace hh_mortality = . if child_mortality==. tab hh_mortality, miss lab var hh_mortality "Household had no child mortality any time" /*Deprived if any children died in the household in the last 5 years from the survey year */ ************************************************************************ tab child_died_per_wom_5y, miss /* The 'child_died_per_wom_5y' variable was constructed in Step 1.2 using information from individual women who ever gave birth in the BR file. The missing values represent eligible woman who have never ever given birth and so are not present in the BR file. But these 'missing women' may be living in households where there are other women with child mortality information from the BR file. So at this stage, it is important that we aggregate the information that was obtained from the BR file at the household level. This ensures that women who were not present in the BR file is assigned with a value, following the information provided by other women in the household.*/ replace child_died_per_wom_5y = 0 if w201==2 replace child_died_per_wom_5y = 0 if w201==1 & w206==2 & child_died_per_wom_5y==. /*Assign a value of "0" for: - all eligible women who never ever gave birth - women who have given birth, no child died but these women skipped the birth history section */ replace child_died_per_wom_5y = 0 if no_fem_eligible==1 /*Assign a value of "0" for: - individuals living in households that have non-eligible women */ bysort hh_id: egen child_mortality_5y = sum(child_died_per_wom_5y), missing *replace child_mortality_5y = 0 if child_mortality_5y==. & child_mortality_m==0 /* NEW */ /*Replace all households as 0 death if women has missing value and men reported no death in those households */ label var child_mortality_5y "Total child mortality within household past 5 years reported by women" tab child_mortality_5y, miss /* The new standard MPI indicator takes a value of "1" if eligible women within the household reported no child mortality or if any child died longer than 5 years from the survey year. The indicator takes a value of "0" if women in the household reported any child mortality in the last 5 years from the survey year. Households were replaced with a value of "1" if eligible men within the household reported no child mortality in the absence of information from women. The indicator takes a missing value if there was missing information on reported death from eligible individuals. */ gen hh_mortality_5y = (child_mortality_5y==0) replace hh_mortality_5y = . if child_mortality_5y==. replace hh_mortality_5y =1 if hh_mortality_5y==. & hh_mortality==1 tab hh_mortality_5y, miss lab var hh_mortality_5y "Household had no child mortality in the last 5 years" /* tab hh_mortality_5y hh_mortality , m Household | had no | child | mortality | in the | Household had no child mortality last 5 | any time years | 0 1 . | Total -----------+---------------------------------+---------- 0 | 730 0 0 | 730 1 | 2,612 59,982 44 | 62,638 . | 2,410 0 1,634 | 4,044 -----------+---------------------------------+---------- Total | 5,752 59,982 1,678 | 67,412 ta women_WM women_BH if hh_mortality_5y==. & hh_mortality==0,m | women_BH women_WM | . | Total -----------+-----------+---------- 1 | 482 | 482 . | 1,928 | 1,928 -----------+-----------+---------- Total | 2,410 | 2,410 */ ******************************************************************************** *** Step 2.5 Electricity *** ******************************************************************************** /*Members of the household are considered deprived if the household has no electricity */ clonevar electricity = q416 codebook electricity, tab (9) replace electricity = 1 if electricity==4 replace electricity = 0 if electricity==2 | electricity==3 | electricity==6 //0=no; 1=yes replace electricity = . if electricity==9 ta q416 electricity,m label var electricity "Household has electricity" ******************************************************************************** *** Step 2.6 Sanitation *** ******************************************************************************** /*Members of the household are considered deprived if the household's sanitation facility is not improved, according to MDG guidelines, or it is improved but shared with other household. We also checked the country reports on how the sanitation categories have been grouped. In cases of mismatch, we have followed the country report */ lookfor toilet clonevar toilet = q413 codebook toilet, tab(30) codebook q414, tab(30) clonevar shared_toilet = q414 recode shared_toilet (2=0) (9=.) tab q414 shared_toilet, miss nol //0=no;1=yes;.=missing gen toilet_mdg = 0 if q413==5 | q413==6 replace toilet_mdg = 1 if q413==1 | q413==2 | q413==3 | q413==4 replace toilet_mdg = 0 if q414==1 /*shared*/ /*Household is assigned a value of '0' if it uses improved sanitation but shares toilet with other households */ lab var toilet_mdg "Household has improved sanitation with MDG Standards" tab toilet toilet_mdg, miss /* Type de toilettes | Freq. Percent Cum. ----------------------------------------+----------------------------------- Toilette avec siphon reliée aux égouts | 34,914 51.79 51.79 1 y Toilette avec siphon non reliée aux égo | 5,896 8.75 60.54 2 y Toilette sans siphon reliée aux égouts | 467 0.69 61.23 3 y Latrine | 22,504 33.38 94.61 4 y En plein air | 3,570 5.30 99.91 5 n Autre | 61 0.09 100.00 6 n ----------------------------------------+----------------------------------- Total | 67,412 100.00 */ ******************************************************************************** *** Step 2.7 Drinking Water *** ******************************************************************************** /*Members of the household are considered deprived if the household does not have access to safe drinking water according to MDG guidelines, or safe drinking water is more than a 30-minute walk from home roundtrip. */ clonevar water = q408 clonevar timetowater = q410 codebook water, tab(100) gen water_mdg = 1 if q408==1 | q408==2 | q408==3 | q408==5 | q408==9 replace water_mdg = 0 if q408==4 | q408==6 | q408==7 | q408==8 | q408==10 | q408==11 | q408==96 replace water_mdg = 0 if timetowater >= 30 & timetowater!=. & timetowater!=998 & timetowater!=999 lab var water_mdg "Household has drinking water with MDG standards (considering distance)" tab water water_mdg, miss /*Because the quality of bottled water is not known, households using bottled water for drinking are classified as using an improved or unimproved source according to their water source for non-drinking activities such as cooking and hand washing. However, it is important to note that households using bottled water for drinking are classified as unimproved source if this is explicitly mentioned in the country report. */ /* Principale souce de l'eau | potable | Freq. Percent Cum. --------------------------+----------------------------------- Réseau public | 42,044 62.37 62.37 1 y Fontaine publique | 4,935 7.32 69.69 2 y Puits avec pompe | 6,584 9.77 79.46 3 y Puits sans pompe | 2,870 4.26 83.71 4 n Source protégée | 1,650 2.45 86.16 5 y Source non protégée | 2,221 3.29 89.46 6 n Rivière / Cours d'eau | 161 0.24 89.69 7 n Etang / Lac | 103 0.15 89.85 8 n Eau de pluie | 412 0.61 90.46 9 y camion-citerne à eau | 2,052 3.04 93.50 10 y Eau minérale en bouteille | 3,447 5.11 98.62 11 y Autre | 933 1.38 100.00 96 n --------------------------+----------------------------------- Total | 67,412 100.00 */ ******************************************************************************** *** Step 2.8 Housing *** ******************************************************************************** /* Members of the household are considered deprived if the household has a dirt, sand or dung floor */ clonevar floor = q403 codebook floor, tab(99) gen floor_imp = 1 if floor==1 | floor==2 | floor==3 | floor==6 replace floor_imp = 0 if q401==5 | q401==6 | q401==96 lab var floor_imp "Household has floor that it is not earth/sand/dung" bys floor_imp: ta q403 q401,m /* Members of the household are considered deprived if the household has wall made of natural or rudimentary materials */ clonevar wall = q405 codebook wall, tab(99) gen wall_imp = 1 if wall==1 replace wall_imp = 0 if wall==2 | wall==3 | wall==6 | q401==5 | q401==6 | q401==96 lab var wall_imp "Household has wall that it is not of low quality materials" bys wall_imp: ta q405 q401,m /* Members of the household are considered deprived if the household has roof made of natural or rudimentary materials */ clonevar roof = q404 codebook roof, tab(99) gen roof_imp = 1 if roof==1 | roof==2 | roof==4 replace roof_imp = 0 if roof==3 | roof==6 | roof==8 | q401==5 | q401==6 | q401==96 lab var roof_imp "Household has roof that it is not of low quality materials" bys roof_imp: ta q404 q401,m /*Household is deprived in housing if the roof, floor OR walls uses low quality materials.*/ gen housing_1 = 1 replace housing_1 = 0 if floor_imp==0 | wall_imp==0 | roof_imp==0 replace housing_1 = . if floor_imp==. & wall_imp==. & roof_imp==. lab var housing_1 "Household has roof, floor & walls that it is not low quality material" tab housing_1, m ******************************************************************************** *** Step 2.9 Cooking Fuel *** ******************************************************************************** /* Members of the household are considered deprived if the household cooks with solid fuels, wood, charcoal, crop residues or dung. "Indicators for Monitoring the Millennium Development Goals", p. 63 */ clonevar cookingfuel = q418 codebook cookingfuel, tab(99) gen cooking_mdg = 1 if cookingfuel<=3 | cookingfuel==6 replace cooking_mdg = 0 if cookingfuel>=4 & cookingfuel<=5 lab var cooking_mdg "Household has cooking fuel by MDG standards" /* Deprived if: "coal/lignite", "charcoal", "wood", "straw/shrubs/grass" "agricultural crop", "animal dung" */ ta cookingfuel cooking_mdg, m ******************************************************************************** *** Step 2.10 Assets ownership *** ******************************************************************************** /* Members of the household are considered deprived if the household does not own more than one of: radio, TV, telephone, bike, motorbike or refrigerator and does not own a car or truck. */ //Check that for standard assets in living standards: "no"==0 and yes=="1" codebook q419_1 q419_2 q419_5 q419_10 q419_11 q419_15 q420_1 q420_2 q420_9 q419_16 clonevar television = q419_1 gen bw_television = . clonevar radio = q419_2 clonevar telephone = q419_10 clonevar mobiletelephone = q419_11 clonevar refrigerator = q419_5 clonevar car = q420_2 gen bicycle = . clonevar motorbike = q420_1 clonevar computer = q419_15 clonevar animal_cart = q420_9 foreach var in television radio telephone mobiletelephone refrigerator car bicycle motorbike computer animal_cart bw_television { replace `var' = 0 if `var'==2 replace `var' = . if `var'==9 | `var'==99 | `var'==8 | `var'==98 } * Group telephone and mobiletelephone as a single variable replace telephone=1 if (telephone==0 | telephone==.) & mobiletelephone==1 replace computer=1 if q419_16==1 /* Members of the household are considered deprived in assets if the household does not own more than one of: radio, TV, telephone, bike, motorbike, refrigerator, computer or animal_cart and does not own a car or truck.*/ egen n_small_assets2 = rowtotal(television radio telephone refrigerator bicycle motorbike computer animal_cart), missing lab var n_small_assets2 "Household Number of Small Assets Owned" gen hh_assets2 = (car==1 | n_small_assets2 > 1) replace hh_assets2 = . if car==. & n_small_assets2==. lab var hh_assets2 "Household Asset Ownership: HH has car or more than 1 small assets incl computer & animal cart" ******************************************************************************** *** Step 2.11 Rename and keep variables for MPI calculation ******************************************************************************** //Generate presence of subsample gen subsample = . *** Rename key global MPI indicators for estimation *** recode hh_mortality_5y (0=1)(1=0) , gen(d_cm) recode hh_nutrition_uw_st (0=1)(1=0) , gen(d_nutr) recode hh_child_atten (0=1)(1=0) , gen(d_satt) recode hh_years_edu6 (0=1)(1=0) , gen(d_educ) recode electricity (0=1)(1=0) , gen(d_elct) recode water_mdg (0=1)(1=0) , gen(d_wtr) recode toilet_mdg (0=1)(1=0) , gen(d_sani) recode housing_1 (0=1)(1=0) , gen(d_hsg) recode cooking_mdg (0=1)(1=0) , gen(d_ckfl) recode hh_assets2 (0=1)(1=0) , gen(d_asst) *** Keep selected variables for global MPI estimation *** keep hh_id ind_id survey year subsample weight area relationship sex age agec7 agec4 marital hhsize region d_cm d_nutr d_satt d_educ d_elct d_wtr d_sani d_hsg d_ckfl d_asst hh_mortality_5y hh_nutrition_uw_st hh_child_atten hh_years_edu6 electricity water_mdg toilet_mdg housing_1 cooking_mdg hh_assets2 country countrycode order hh_id ind_id country countrycode survey year subsample weight area relationship sex age agec7 agec4 marital hhsize region d_cm d_nutr d_satt d_educ d_elct d_wtr d_sani d_hsg d_ckfl d_asst hh_mortality_5y hh_nutrition_uw_st hh_child_atten hh_years_edu6 electricity water_mdg toilet_mdg housing_1 cooking_mdg hh_assets2 *** Sort, compress and save data for estimation *** sort ind_id compress save "$path_out/Morocco_PAPFAM18_pov.dta", replace log close ******************************************************************************** *** MPI Calculation (TTD file) ******************************************************************************** **SELECT COUNTRY POV FILE RUN ON LOOP FOR MORE COUNTRIES use "$path_out\Morocco_PAPFAM18_pov.dta", clear ******************************************************************************** *** Define Sample Weight and total population *** ******************************************************************************** gen sample_weight = weight ******************************************************************************** *** List of the 10 indicators included in the MPI *** ******************************************************************************** gen edu_1 = hh_years_edu6 gen atten_1 = hh_child_atten gen cm_1 = hh_mortality_5y /* change countries with no child mortality 5 year to child mortality ever*/ gen nutri_1 = hh_nutrition_uw_st gen elec_1 = electricity gen toilet_1 = toilet_mdg gen water_1 = water_mdg gen house_1 = housing_1 gen fuel_1 = cooking_mdg gen asset_1 = hh_assets2 global est_1 edu_1 atten_1 cm_1 nutri_1 elec_1 toilet_1 water_1 house_1 fuel_1 asset_1 ******************************************************************************** *** List of sample without missing values *** ******************************************************************************** foreach j of numlist 1 { gen sample_`j' = (edu_`j'!=. & atten_`j'!=. & cm_`j'!=. & nutri_`j'!=. & elec_`j'!=. & toilet_`j'!=. & water_`j'!=. & house_`j'!=. & fuel_`j'!=. & asset_`j'!=.) replace sample_`j' = . if subsample==0 /* Note: If the anthropometric data was collected from a subsample of the total population that was sampled, then the final analysis only includes the subsample population. */ *** Percentage sample after dropping missing values *** sum sample_`j' [iw = sample_weight] gen per_sample_weighted_`j' = r(mean) sum sample_`j' gen per_sample_`j' = r(mean) } *** ******************************************************************************** *** Define deprivation matrix 'g0' *** which takes values 1 if individual is deprived in the particular *** indicator according to deprivation cutoff z as defined during step 2 *** ******************************************************************************** foreach j of numlist 1 { foreach var in ${est_`j'} { gen g0`j'_`var' = 1 if `var'==0 replace g0`j'_`var' = 0 if `var'==1 } } *** Raw Headcount Ratios foreach j of numlist 1 { foreach var in ${est_`j'} { sum g0`j'_`var' if sample_`j'==1 [iw = sample_weight] gen raw`j'_`var' = r(mean)*100 lab var raw`j'_`var' "Raw Headcount: Percentage of people who are deprived in `var'" } } ******************************************************************************** *** Define vector 'w' of dimensional and indicator weight *** ******************************************************************************** /*If survey lacks one or more indicators, weights need to be adjusted within / each dimension such that each dimension weighs 1/3 and the indicator weights add up to one (100%). CHECK COUNTRY FILE*/ foreach j of numlist 1 { // DIMENSION EDUCATION foreach var in edu_`j' atten_`j' { capture drop w`j'_`var' gen w`j'_`var' = 1/6 } // DIMENSION HEALTH foreach var in cm_`j' nutri_`j' { capture drop w`j'_`var' gen w`j'_`var' = 1/6 } // DIMENSION LIVING STANDARD foreach var in elec_`j' toilet_`j' water_`j' house_`j' fuel_`j' asset_`j' { capture drop w`j'_`var' gen w`j'_`var' = 1/18 } } ******************************************************************************** *** Generate the weighted deprivation matrix 'w' * 'g0' ******************************************************************************** foreach j of numlist 1 { foreach var in ${est_`j'} { gen w`j'_g0_`var' = w`j'_`var' * g0`j'_`var' replace w`j'_g0_`var' = . if sample_`j'!=1 /*The estimation is based only on observations that have non-missing values for all variables in varlist_pov*/ } } ******************************************************************************** *** Generate the vector of individual weighted deprivation count 'c' ******************************************************************************** foreach j of numlist 1 { egen c_vector_`j' = rowtotal(w`j'_g0_*) replace c_vector_`j' = . if sample_`j'!=1 *drop w_g0_* } ******************************************************************************** *** Identification step according to poverty cutoff k (20 33.33 50) *** ******************************************************************************** foreach j of numlist 1 { foreach k of numlist 20 33 50 { gen multidimensionally_poor_`j'_`k' = (c_vector_`j'>=`k'/100) replace multidimensionally_poor_`j'_`k' = . if sample_`j'!=1 //Takes value 1 if individual is multidimensional poor } } ******************************************************************************** *** Generate the censored vector of individual weighted deprivation count 'c(k)' ******************************************************************************** foreach j of numlist 1 { foreach k of numlist 20 33 50 { gen c_censured_vector_`j'_`k' = c_vector_`j' replace c_censured_vector_`j'_`k' = 0 if multidimensionally_poor_`j'_`k'==0 } //Provide a score of zero if a person is not poor } * ******************************************************************************** *** Define censored deprivation matrix 'g0(k)' *** ******************************************************************************** foreach j of numlist 1 { foreach var in ${est_`j'} { gen g0`j'_k_`var' = g0`j'_`var' replace g0`j'_k_`var' = 0 if multidimensionally_poor_`j'_33==0 replace g0`j'_k_`var' = . if sample_`j'!=1 } } ******************************************************************************** *** Generates Multidimensional Poverty Index (MPI), *** Headcount (H) and Intensity of Poverty (A) *** ******************************************************************************** *** Multidimensional Poverty Index (MPI) *** foreach j of numlist 1 { foreach k of numlist 20 33 50 { sum c_censured_vector_`j'_`k' [iw = sample_weight] if sample_`j'==1 gen MPI_`j'_`k' = r(mean) lab var MPI_`j'_`k' "MPI with k=`k'" } sum c_censured_vector_`j'_33 [iw = sample_weight] if sample_`j'==1 gen MPI_`j' = r(mean) lab var MPI_`j' "`j' Multidimensional Poverty Index (MPI = H*A): Range 0 to 1" *** Headcount (H) *** sum multidimensionally_poor_`j'_33 [iw = sample_weight] if sample_`j'==1 gen H_`j' = r(mean)*100 lab var H_`j' "`j' Headcount ratio: % Population in multidimensional poverty (H)" *** Intensity of Poverty (A) *** sum c_censured_vector_`j'_33 [iw = sample_weight] if multidimensionally_poor_`j'_33==1 & sample_`j'==1 gen A_`j' = r(mean)*100 lab var A_`j' "`j' Intensity of deprivation among the poor (A): Average % of weighted deprivations" *** Population vulnerable to poverty (who experience 20-32.9% intensity of deprivations) *** gen temp = 0 replace temp = 1 if c_vector_`j'>=0.2 & c_vector_`j'<0.3332 replace temp = . if sample_`j'!=1 sum temp [iw = sample_weight] gen vulnerable_`j' = r(mean)*100 lab var vulnerable_`j' "`j' % Population vulnerable to poverty (who experience 20-32.9% intensity of deprivations)" drop temp *** Population in severe poverty (with intensity 50% or higher) *** gen temp = 0 replace temp = 1 if c_vector_`j'>0.49 replace temp = . if sample_`j'!=1 sum temp [iw = sample_weight] gen severe_`j' = r(mean)*100 lab var severe_`j' "`j' % Population in severe poverty (with intensity 50% or higher)" drop temp } * *** Censored Headcount *** foreach j of numlist 1 { foreach var in ${est_`j'} { sum g0`j'_k_`var' [iw = sample_weight] if sample_`j'==1 gen cen`j'_`var' = r(mean)*100 lab var cen`j'_`var' "Censored Headcount: Percentage of people who are poor and deprived in `var'" } } *** Dimensional Contribution *** foreach j of numlist 1 { foreach var in ${est_`j'} { gen cont`j'_`var' = (w`j'_`var' * cen`j'_`var')/MPI_`j' if sample_`j'==1 lab var cont`j'_`var' "% Contribution in MPI of indicator..." } } ** The line below produces the variance (inequality among the poor) ** sum c_vector_1 if c_vector_1>=1/3 & c_vector_1<=1 [aw = sample_weight], detail gen var=r(Var) *** Prepare results to export *** keep country year survey per_sample_weighted* per_sample* MPI* H* A* vulnerable* severe* raw* cen* cont* var *gen temp = (_n) *keep if temp==1 *drop temp order MPI_1 H_1 A_1 severe_1 vulnerable_1 var cont1_nutr cont1_cm_1 cont1_edu_1 cont1_atten_1 cont1_fuel_1 cont1_toilet_1 cont1_water_1 cont1_elec_1 cont1_house_1 cont1_asset_1 per_sample_1 per_sample_weighted_1 raw1_nutri_1 raw1_cm_1 raw1_edu_1 raw1_atten_1 raw1_fuel_1 raw1_toilet_1 raw1_water_1 raw1_elec_1 raw1_house_1 raw1_asset_1 cen1_nutri_1 cen1_cm_1 cen1_edu_1 cen1_atten_1 cen1_fuel_1 cen1_toilet_1 cen1_water_1 cen1_elec_1 cen1_house_1 cen1_asset_1 codebook, compact *clear