** Morocco 2011 ** ** HH DEPRIVATIONS ** /* REFORMULATED MPI - MAY 7 2013 */ /* A household is deprived in LIVING STANDARDS if it a. Does not have electricity or Has electricity but neither has a television nor a refrigerator b. Does not use improved drinking water sources (MDG indicator 7.8) c. Does not use improved sanitation (MDG indicator 7.9) d. Uses solid fuel for cooking and heating (non-MDG indicator related to target 7) e. Does not have the finished floor (non-MDG indicator related to Target 7). Weighting: each indicator is weighted by 1/5 A household is poor in Living standards if the sum of weighted deprivations is 1/3 or more. */ clear clear matrix set more off *set maxvar 7000 cd "C:\Users\cecilia.calderon\Documents\HDRO_MCC\MPI\MPI_new calculations\Morocco 2011_PAPFAM\" use "morocco_2011_hh.dta", clear gen weight = hhweight gen hhmembers_hh = qhmember gen urban = 1 if qhmili==1 replace urban = 0 if qhmili==2 * ELECTRICITY * gen electricity = 1 if h317==1 replace electricity = 0 if h317>=2 & h317<=8 * DRINKING WATER * gen water = 1 if h308==1 | h308==2 | h308==3 | h308==4 | h308==5 | h308==9 replace water = 0 if h308==6 | h308==7 | h308==8 | h308==10 | h308==11 | h308==96 replace water = 0 if (h310>=30 & h310<=460) | (h310==998 & (h308==1 | h308==2 | h308==3 | h308==4 | h308==5 | h308==9)) /* r?seau public | 9,586 62.48 62.48 1 y robinet public (fontaine) | 1,584 10.32 72.81 2 y puit ?quip? d'une pompe | 919 5.99 78.80 3 y puit, pas ?quip? d'une pompe | 1,025 6.68 85.48 4 y source surveill? | 201 1.31 86.79 5 y source non surveill? | 826 5.38 92.17 6 n rivi?re / ruisseau | 109 0.71 92.88 7 n lac | 18 0.12 93.00 8 n eau des pluits | 258 1.68 94.68 9 y v?hicule ?quip? d'un r?servoir d'eau | 319 2.08 96.76 10 n l'eau min?rale en verre ou en plastique | 333 2.17 98.93 11 n autre | 164 1.07 100.00 96 n */ * SANITATION * gen sanitation = 0 if h314==5 | h314==6 | h314==7 replace sanitation = 1 if h314==1 | h314==2 | h314==3 | h314==4 replace sanitation = 0 if h315==1 /*shared*/ /* toilette branch?e a l'?gout | 8,305 54.20 54.20 1 y toilette avec sifon branch? a l'?goux | 2,232 14.57 68.77 2 y toilette branch? a l'?goux | 144 0.94 69.71 3 y toilette branchee a fosse septique | 2,986 19.49 89.19 4 y toilette publique | 44 0.29 89.48 5 n dans la nature | 1,595 10.41 99.89 6 n autres | 17 0.11 100.00 7 n */ * COOKING FUEL * gen cookingfuel = 0 if h319==4 | h319==5 | h319==6 replace cookingfuel = 1 if h319==1 | h319==2 | h319==3 * FLOOR * gen floor = 1 if h303==2 | h303==3 | h303==4 | h303==5 | (h303==. & (h301==1 | h301==2 | h301==3 | h301==4)) replace floor = 0 if h303==1 | h303==6 | (h303==. & (h301==5 | h301==6 | h301==7 | h301==96)) * ASSETS * /* Household is not deprived in assets if it owns at least one of the assets for access to information (phone (mobile or fixed), radio, TV) AND either one asset for easy mobility (bicycle, motorbike, motorboat, car, truck or animal wheel cart) OR one asset for livelihood (refrigerator, agricultural land or livestock (at least one cattle or at least one horse or at least two goats or at least two sheep, or at least 10 chicken) */ *h328c byte %8.0g h328c animaux b?tail *h328d byte %8.0g h328d volailles (poultry) foreach var in h324a h324b h324e h324j h324k h328a h328b h328c h328d h328e h328l { replace `var'=. if `var'==9 replace `var'=0 if `var'==2 } * Information * gen phone = 0 if h324j==0 & h324k==0 replace phone = 1 if h324j==1 | h324k==1 /* cell phone or landline */ gen radio = 0 if h324a==0 replace radio = 1 if h324a==1 gen tv = 0 if h324b==0 replace tv = 1 if h324b==1 * Mobility * *gen bicycle = 0 if hv210==0 *replace bicycle = 1 if hv210==1 gen motorcycle = 0 if h328a==0 replace motorcycle = 1 if h328a==1 *gen motorboat = 0 if hv243d==0 *replace motorboat = 1 if hv243d==1 gen car_truck = 0 if h328b==0 | h328e==0 replace car_truck = 1 if h328b==1 & h328e==1 *gen animal_cart = 0 if hv243c==0 *replace animal_cart = 1 if hv243c==1 * Livelihood * gen refrigerator = 0 if h324e==0 replace refrigerator = 1 if h324e==1 gen land = 0 if h328l==0 replace land = 1 if h328l==1 /* gen cattle = 0 if hv246a==0 & hv246b==0 replace cattle = 1 if (hv246a>0 & hv246a<=95) | (hv246b>0 & hv246b<=95) gen horses = 0 if hv246c==0 replace horses = 1 if (hv246c>0 & hv246c<=95) gen goats = 0 if hv246d<2 replace goats = 1 if (hv246d>=2 & hv246d<=95) gen sheeps = 0 if hv246e<2 replace sheeps = 1 if (hv246e>=2 & hv246e<=95) gen chicken = 0 if hv246f<10 replace chicken = 1 if (hv246f>=10 & hv246f<=95)*/ egen information_miss = rowmiss(phone radio tv) egen mobility_miss = rowmiss(car_truck motorcycle) egen livelihood_miss = rowmiss(refrigerator land) gen information_depriv = . if information_miss==2 | information_miss==3 replace information_depriv = 0 if phone==1 | radio==1 | tv==1 replace information_depriv = 1 if phone==0 & radio==0 & tv==0 gen mobility_depriv = . if mobility_miss==2 replace mobility_depriv = 0 if car_truck==1 | motorcycle==1 replace mobility_depriv = 1 if car_truck==0 & motorcycle==0 gen livelihood_depriv = 0 if refrigerator== 1 | land==1 replace livelihood_depriv = 1 if refrigerator==0 & land==0 gen asset_depriv = . if information_depriv==. | (information_depriv==1 & mobility_depriv==0 & livelihood_depriv==.) | (information_depriv==1 & mobility_depriv==. & livelihood_depriv==0) replace asset_depriv = 0 if information_depriv==0 & (mobility_depriv==0 | livelihood_depriv==0) replace asset_depriv = 1 if information_depriv==1 | (information_depriv==0 & mobility_depriv==1 & livelihood_depriv==1) foreach var in sanitation water floor cookingfuel electricity { gen `var'_depriv=1 if `var'==0 replace `var'_depriv=0 if `var'==1 } egen depriv = rsum(electricity_depriv sanitation_depriv water_depriv floor_depriv cookingfuel_depriv asset_depriv) replace depriv = . if electricity_depriv==. & sanitation_depriv==. & water_depriv==. & floor_depriv==. & cookingfuel_depriv==. & asset_depriv==. gen ls_sample=1 if electricity_depriv<. & sanitation_depriv<. & water_depriv<. & floor_depriv<. & cookingfuel_depriv<. & asset_depriv<. egen livings_miss = rowmiss(electricity_depriv sanitation_depriv water_depriv floor_depriv cookingfuel_depriv asset_depriv) keep if qhresult==1 /* completed HH interview */ sort cluster hhnum keep weight hhmembers_hh urban electricity electricity_depriv water sanitation cookingfuel floor sanitation_depriv water_depriv floor_depriv cookingfuel_depriv depriv ls_sample livings_miss phone radio tv car_truck refrigerator information_miss mobility_miss livelihood_miss information_depriv mobility_depriv livelihood_depriv asset_depriv cluster hhnum qhregion save "HH_MPI2_MCC.dta", replace * WOMEN'S QUESTIONNAIRE (15-49 y) * use "morocco_2011_wom.dta", clear gen child_died=0 if q206==2 replace child_died=1 if q206==1 *egen child_diedhh=sum(child_died), by(cluster hhnum) egen children_died=rsum(xq207ar xq207br) replace children_died=. if qresult>1 *egen children_diedhh=sum(children_died), by(cluster hhnum) *replace children_diedhh = 1 if children_diedhh>1 & children_diedhh<. *replace child_diedhh = 1 if child_diedhh>1 & child_diedhh<. gen uno=1 egen nwomen15_49=sum(uno), by(cluster hhnum) drop uno ta children_died child_died,m keep cluster hhnum ln children_died child_died nwomen15_49 qresult sort cluster hhnum ln save "morocco_2011_wom_MCC.dta", replace * INDIVIDUALS' QUESTIONNAIRE * use "morocco_2011_hr.dta", clear ren h101 ln gen age = h109age gen sex = 1 if h103==1 replace sex = 0 if h103==2 sort cluster hhnum merge cluster hhnum using "HH_MPI2_MCC.dta" tab _merge ren _merge merge_hh sort cluster hhnum ln merge cluster hhnum ln using "morocco_2011_wom_MCC.dta" tab _merge drop if _merge==2 ren _merge merge_women_i egen hh=group(cluster hhnum) egen hhid=group(cluster hhnum) gen uno=1 egen hhmembers=sum(uno), by(hh) compare hhmembers hhmembers_hh drop hhmembers uno drop if h104==9 | h104==. gen uno=1 egen hhmembers=sum(uno), by(hh) compare hhmembers hhmembers_hh label var hhmembers "Number of HH members (only usual residents, excludes visitors)" label var hhmembers_hh "Number of HH members (usual residents + visitors)" drop uno compress sort cluster hhnum ln save "Morocco_MPI2_2011.dta", replace * MPI CALCULATION * *** A- EDUCATION DIMENSION *** /* For the indicator on years of education, if we observe at least one member with five or more years of education then, regardless of the number of other members with missing data, we classify the household as non-deprived. If more than 1/3 of the household members have missing information on years of education, and the people for which we observe the years of education have less than five years, the household is given a missing value in this indicator. If we have information of 2/3 (or more) of household members, and these report less than five years of education, the household will be classified as deprived. For the school attendance indicator, if all school-aged children in a household have missing information in enrolment, that value is considered missing. As long as we have information for one of the children in the household, the household will be classified as non-deprived or deprived depending on whether that child is reported to be attending school or not. */ * http://stats.uis.unesco.org/unesco/TableViewer/tableView.aspx?ReportId=163 * Entrance age of primary: 6y * Duration of primary: 6y * Entrance age of lower secondary: 12y * Durantion lower secondary: 3y * Entrance age high secondary: 15y * Duration high secondary: y /* reviewed July 1st 2013 */ ** 1- DEPRIVED IN EDUCATION ** *gen yschooling = hr13 if hr13<90 *replace yschooling = 0 if hr12==4 & age>=5 *replace yschooling=. if age<5 gen uno14=1 if age>=12 & age<. /* Number of HH members 12y or older */ bys cluster hhnum: egen hhmember14 = sum(uno14) ** 1- DEPRIVED IN EDUCATION ** gen yschoolingi=0 if (edulevel==0 | edulevel==1) & age>=12 & age<. replace yschoolingi=1 if (edulevel==2 | edulevel==3 | edulevel==4 | edulevel==5 | edulevel==6 ) gen schooling_missing = 1 if (edulevel==. | edulevel==7) & age>=12 & age<. egen schooling_missinghh=sum(schooling_missing), by(cluster hhnum) egen yeduchh=sum(yschoolingi), by(cluster hhnum) /* assumes that a member has <6 y schooling when there is missing info on that member's schooling */ replace yeduchh=. if schooling_missinghh==hhmember14 * DEPRIVED IN EDUCATION INDICATOR * gen educ_depriv=1 if yeduchh==0 replace educ_depriv=0 if yeduchh>=1 & yeduchh<. replace educ_depriv=. if yeduchh ==0 & schooling_missinghh>0 & schooling_missinghh>(1/3*hhmember14) ** 2- DEPRIVED IN SCHOOL ATTENDANCE 7-14Y (entrance age is 6 but we allow for 1 year of late enrollment) ** gen attendance_missing=1 if h109a==. & age>=7 & age<=14 gen child_7_14=1 if age>=7 & age<=14 egen attendance_missinghh=sum(attendance_missing), by(cluster hhnum) egen child_7_14hh=sum(child_7_14), by(cluster hhnum) gen child_6_14=1 if age>=6 & age<=14 egen child_6_14hh=sum(child_6_14), by(cluster hhnum) gen attendance_missing_final = 1 if attendance_missinghh==child_7_14hh & child_7_14hh>0 & attendance_missing==1 & child_7_14==1 egen attendance_missing_finalhh = sum(attendance_missing_final), by(cluster hhnum) gen child_noattend=1 if (h109a==2 | h109a==3) & age>=7 & age<=14 replace child_noattend=0 if h109a==1 & age>=7 & age<=14 * DEPRIVED IN SCHOOL ATTENDANCE 7-14Y * egen child_noattendhh=sum(child_noattend), by(cluster hhnum) replace child_noattendhh=1 if child_noattendhh>1 & child_noattendhh<. replace child_noattendhh=. if child_noattendhh==0 & attendance_missinghh>=1 & attendance_missinghh>(1/3*child_7_14hh) replace child_noattendhh=0 if child_6_14hh>0 & child_6_14hh<. & child_7_14hh==0 sort cluster hhnum ln save "Morocco_MPI2_2011.dta", replace *** B- HEALTH DIMENSION *** /* For the nutritional indicator, in DHS countries, if nutritional information for women and children in the household was missing and these were households with applicable members (that is with children and/or women), we consider the household as missing this indicator. Otherwise, we used the available information. Similarly, for child mortality, households that had applicable members who did not respond to the mortality question are considered to be missing this information; otherwise the household is considered non-deprived. */ ** 1- DEPRIVED IN NUTRITION ** /* Adults are considered malnourished if their BMI is below 18.5. Children are considered malnourished if their z-score of weight-for-age is below minus two standard deviations from the median of the reference population. DHS contains nutritional information on women between 15 and 49 years (Body Mass Index, BMI hereafter) and on the under-5-year-old children of the household (weight and height). This allows constructing a composite indicator which considers a household to be deprived (and therefore all its members) if there is either a woman or a child undernourished in the household. */ ** CHILDREN UNDERNUTRITION USING WHO Z SCORES ** /* clear set maxvar 7000 set mem 500m set more off cd "C:\Users\cecilia.calderon\Documents\HDRO_MCC\MPI\MPI_new calculations\Morocco 2011_PAPFAM\" use "Morocco_MPI2_2011.dta", clear keep cluster hhnum ln sex age agemonth h404 h405 h406 h407 weight * Variable “Sex” (1=male; 2=female) gen gender = 1 if sex==1 replace gender=2 if sex==0 desc gender tab gender * Variable “Age”can be expresses it in months or days tab agemonth, miss codebook agemonth gen age_months = agemonth desc age_months summ age_months gen str6 ageunit = "months" label var ageunit "Months" *Variable “Sampling weight” ren weight sw desc sw summ sw * Variable “body weight” – it must be in kilograms ta h404, miss codebook h404 gen weight = h404 if h404<90 desc weight summ weight * Variable “height” – it must be in centimetres ta h405, miss codebook h405 gen height = h405 if h405<990 desc height summ height codebook gen measure = "l" if h406==1 replace measure = "h" if h406==2 replace measure = " " if h406==. desc measure tab measure *Variable “Oedema” gen oedema=. desc oedema keep cluster hhnum ln gender age_months ageunit weight height oedema measure sw h405 h404 h406 h407 sort cluster hhnum ln save "C:\Users\cecilia.calderon\Documents\HDRO_MCC\MPI\WHO igrowup STATA\WHO igrowup workdata\MORO11_survey.dta", replace * THIS RUNS THE ANTHRO ADO FILE FROM WHO * /* Example: survey_standard.do using survey.dta */ clear set more 1 /* Higher memory might be necessary for larger datasets */ set memory 500m set maxvar 10000 /* Indicate to the Stata compiler where the igrowup_standard.ado file is stored*/ adopath + "C:\Users\cecilia.calderon\Documents\HDRO_MCC\MPI\WHO igrowup STATA\" /* Load the data file */ use "C:\Users\cecilia.calderon\Documents\HDRO_MCC\MPI\WHO igrowup STATA\WHO igrowup workdata\MORO11_survey.dta", clear /* generate the first three parameters reflib, datalib & datalab */ gen str60 reflib="C:\igrowup_stata" lab var reflib "Directory of reference tables" gen str60 datalib="C:\Users\cecilia.calderon\Documents\HDRO_MCC\MPI\WHO igrowup STATA\WHO igrowup workdata" lab var datalib "Directory for datafiles" gen str30 datalab="MORO11_survey" lab var datalab "Working file" /* check the variable for "sex" 1 = male, 2=female */ desc gender tab gender /* check the variable for "age" */ ren age_months agemons desc agemons summ agemons /* define your ageunit */ *gen str6 ageunit="months" /* or gen ageunit="days" */ *lab var ageunit "=days or =months" /* check the variable for body "weight" which must be in kilograms*/ /* NOTE: if not available, please create as [gen weight=.]*/ desc weight summ weight /* check the variable for "height" which must be in centimeters*/ /* NOTE: if not available, please create as [gen height=.]*/ desc height summ height /* check the variable for "measure"*/ /* NOTE: if not available, please create as [gen str1 measure=" "]*/ desc measure tab measure /* check the variable for "headc" which must be in centimeters*/ /* NOTE: if not available, please create as [gen headc=.]*/ gen headc=. desc head summ head /* check the variable for "armc" which must be in in centimeters*/ /* NOTE: if not available, please create as [gen armc=.]*/ gen muac=. desc muac summ muac /* check the variable for "triskin" which must be in millimeters*/ /* NOTE: if not available, please create as [gen triskin=.]*/ gen triskin=. desc tri summ tri /* check the variable for "subskin" which must be in millimeters*/ /* NOTE: if not available, please create as [gen subskin=.]*/ gen subskin=. desc sub summ sub /* check the variable for "oedema"*/ /* NOTE: if not available, please create as [gen str1 oedema="n"]*/ desc oedema tab oedema /* check the variable for "sw" for the sampling weight*/ /* NOTE: if not available, please create as [gen sw=1]*/ desc sw summ sw /* Fill in the macro parameters to run the command */ igrowup_standard reflib datalib datalab gender agemons ageunit weight height measure head muac tri sub oedema sw keep cluster hhnum ln agemons height _zwei _zlen _zbmi _zwfl _fwfl _flen _fwei _fbmi h405 h404 sort cluster hhnum ln save "MORO11_anthro.dta", replace */ use "Morocco_MPI2_2011.dta", clear sort cluster hhnum ln merge cluster hhnum ln using "MORO11_anthro.dta" tab _merge ren _merge merge_anthro * UNDERNUTRITION USING Z SCORES CALCULATED WITH WHO CODE * * Height-for-age * gen zha = _zlen if _flen==0 gen malnourished5 = 1 if zha<=-2 replace malnourished5=0 if zha>-2 & zha<. egen malnourished5hh=sum(malnourished5), by (cluster hhnum) missing gen missing_zha=1 if (_flen==1 | ((h407==2 | h407==3 | h407==4 | h407==5 | h407==6) & height==.) | h405>990 & h405<.) & agemons<=60 egen missing_zhahh=sum(missing_zha), by(cluster hhnum) missing gen nomissing_zha=1 if _flen==0 egen nomissing_zhahh=sum(nomissing_zha), by(cluster hhnum) missing gen missing_zha_finalhh=1 if missing_zhahh>=1 & missing_zhahh<. & nomissing_zhahh==. replace missing_zha_finalhh=0 if missing_zha_finalhh==. gen uno_zha=1 if zha<. egen nw_zha=sum(uno_zha), by (cluster hhnum) gen uno0_5=1 if agemons<=60 bys cluster hhnum: egen hhmember0_5 = sum(uno0_5) ren malnourished5hh nmalnourished5hh gen malnourished5hh=1 if nmalnourished5hh>=1 & nmalnourished5hh<. replace malnourished5hh=0 if nmalnourished5hh==0 replace missing_zha_finalhh=1 if malnourished5hh==0 & hhmember0_5>(2*nw_zha) & nw_zha<. replace missing_zhahh=1 if malnourished5hh==0 & hhmember0_5>(2*nw_zha) & nw_zha<. replace malnourished5hh=. if malnourished5hh==0 & hhmember0_5>(2*nw_zha) & nw_zha<. gen w=1 if sex==0 & age>=15 & age<=49 egen whh=sum(w), by(cluster hhnum) gen welig=1 if sex==0 & age>=15 & age<. egen welighh=sum(welig), by(cluster hhnum) gen undernutritionhh=0 if malnourished5hh==0 replace undernutritionhh=1 if malnourished5hh>0 & malnourished5hh<. replace undernutritionhh=0 if undernutritionhh==. & welighh>0 & hhmember0_5==0 sort cluster hhnum save "Morocco_MPI2_2011.dta", replace ** 2- DEPRIVED IN MORTALITY ** * We assume that never married women 15-49y were not asked the fertility questionnaire because they did not have children and, thus, are not deprived in mortality * replace child_died = 0 if child_died==. & w==1 & merge_women_i==1 & h106==1 replace children_died = 0 if children_died==. & w==1 & merge_women_i==1 & h106==1 replace children_died=1 if children_died>1 & children_died<. gen w35=1 if sex==0 & age>=15 & age<=35 & age<. egen w35hh=sum(w35), by(cluster hhnum) gen child_died5 = children_died replace child_died5=0 if child_died5==1 & age>35 & age<=49 & merge_w==3 replace child_died5=0 if child_died5==. & age>35 & age<=49 & merge_w==3 capture drop uno gen uno=1 if child_died5==. & age>=15 & age<=35 & sex==0 egen missing_child_died5hh=sum(uno), by(cluster hhnum) capture drop uno gen uno=1 if child_died5<. & age>=15 & age<=35 & sex==0 egen nomissing_child_died5hh=sum(uno), by(cluster hhnum) egen child_died5hh=sum(child_died5), by(cluster hhnum) missing egen children_diedhh=sum(children_died), by(cluster hhnum) missing replace children_diedhh=0 if children_diedhh==. & whh==0 *replace child_died5hh=0 if children_diedhh==0 & child_died5hh==. replace child_died5hh=0 if w35hh==0 gen mortality5hh=0 if child_died5hh==0 replace mortality5hh=1 if child_died5hh>=1 & child_died5hh<. egen merge_women=max(merge_women_i), by(cluster hhnum) replace merge_women=. if merge_women_i==. & merge_women==3 gen region = qhregion compress sort cluster hhnum save "Morocco_MPI2_2011.dta", replace * NON-ELIGIBLE POPULATION * gen uno7_14=1 if age>=7 & age<=14 bys cluster hhnum: egen hhmember7_14 = sum(uno7_14) gen uno15_49=1 if age>=15 & age<=49 & sex==0 bys cluster hhnum: egen hhmember15_49 = sum(uno15_49) *bys cluster hhnum: egen hhmember0_5 = sum(uno0_5) gen uno7_14hh=0 if hhmember7_14==0 replace uno7_14hh=1 if hhmember7_14>=1 & hhmember7_14<. gen uno15_49hh=0 if hhmember15_49==0 replace uno15_49hh=1 if hhmember15_49>=1 & hhmember15_49<. gen uno0_5hh=0 if hhmember0_5==0 replace uno0_5hh=1 if hhmember0_5>=1 & hhmember0_5<. gen uno15_35=1 if age>=15 & age<=35 & sex==0 bys cluster hhnum: egen hhmember15_35 = sum(uno15_35) gen uno15_35hh=0 if hhmember15_35==0 replace uno15_35hh=1 if hhmember15_35>=1 & hhmember15_35<. gen nutrihh=1 if undernutritionhh<. & malnourished5hh<. replace nutrihh=2 if undernutritionhh==. & malnourished5hh==. & hhmember0_5>0 & hhmember0_5<. replace nutrihh=3 if undernutritionhh==0 & malnourished5hh==. & hhmember0_5==0 & welighh>0 & welighh<. replace nutrihh=4 if undernutritionhh==. & malnourished5hh==. & hhmember0_5==0 & welighh==0 label define nutrihh 1 "HH with nutrition information" 2 "HH with missing information on nutrition" 3 "HH with no eligible population for nutrition (no children 0-5y) but with women 15-49y" 4 "HH with no children 0-5 and no women 15-49y" label values nutrihh nutrihh gen attehh=1 if child_noattendhh<. & uno7_14hh==1 replace attehh=2 if child_noattendhh==. replace attehh=3 if child_noattendhh==0 & uno7_14hh==0 replace attehh=1 if attehh==3 & child_6_14hh>0 & child_6_14hh<. & child_7_14hh==0 label define attehh 1 "HH with attendance information" 2 "HH with missing information on attendance" 3 "HH with no eligible population for attendace (no children 7-14y)" label values attehh attehh gen morthh=1 if mortality5hh<. & uno15_35hh==1 replace morthh=1 if mortality5hh==0 & w35hh==0 replace morthh=3 if welighh==0 replace morthh=4 if mortality5hh==. & merge_women==1 & uno15_35hh==1 replace morthh=2 if mortality5hh==. & merge_women==3 & uno15_35hh==1 replace mortality5hh=0 if mortality5hh==. & merge_women==1 replace mortality5hh=. if mortality5hh==0 & w35hh>(2*nomissing_child_died5hh) & nomissing_child_died5hh<. replace morthh=2 if morthh==1 & mortality5hh==. & w35hh>(2*nomissing_child_died5hh) & nomissing_child_died5hh<. label define morthh 1 "HH with mortality information" 2 "HH with missing information on mortality" 3 "HH with no eligible population for mortality (no women 15-49y)" 4 "HH with eligible population for mortality but do not appear in fertility section" label values morthh morthh compress sort cluster hhnum save "Morocco_MPI2_2011.dta", replace ** DO FILE FROM OPHI TO COMPUTE MPI ** *************************************************************************** **** Multidimensional Poverty Measure ************************************* **** OPHI-HDCA Summer School 2011 ***************************************** **** 24 August to 3 September 2011 - Delft, the Netherlands *************** *************************************************************************** ** ADAPTED BY CECILIA ON MAY 2013 ** ** Morocco 2011 ** clear set more off set maxvar 10000 set mem 500m cap log close *** Replace here your path to the dataset*** cd "C:\Users\cecilia.calderon\Documents\HDRO_MCC\MPI\MPI_new calculations\Morocco 2011_PAPFAM\" *** Replace here the name of your dataset*** capture log close log using "M0_dofile_Morocco2011_MPI2.log", text replace use "Morocco_MPI2_2011.dta", clear ********************************************************************************* ******* Define the deprivation matrix **************************************** ********************************************************************************* *** The dataset can be interpreted as the matrix of achivemnts *** We will now crate the deprivation matrix based on the indicator definition; and deprivation cut-off defined by you *** during the last working session on the normative Issues in Multidimensional Poverty Measure *** In order to do this, we will generate a new variable for each indicator contained in our measure *** This will identify with 0 individuals or households who are not deprived in the specific indicator *** and identify with 1 individual deprived in the specific indicator. *** Note that you will need to replace with dot "." if the information is missing or inconsistent. *** We will assess later the frequency of missing values. ** DEPRIVED IN DRINKING WATER ** (the individual -HH- is considered deprived in drinking water is: unprotected well, spring, river/lake/pond or other) /*lookfor water codebook b2q12, tab(20) gen d_dwater=(b2q12==5 | b2q12==6 | b2q12==7 | b2q12==8) replace d_dwater=. if b2q12==. tab b2q12 d_dwater [aw=weight], miss label variable d_dwater "Deprived in drinking water"ic*/ ** Please follow the same logic for all indicators. ** Note that for advance indicator you may have to use more complex algorithms ***************************************************************************** ******** Create a local variable with all your indicators ********* ***************************************************************************** local varlist_pov electricity_depriv sanitation_depriv water_depriv floor_depriv cookingfuel_depriv asset_depriv educ_depriv child_noattendhh undernutritionhh mortality5hh ***************************************************************************** **** Define the weights ***************************** ***************************************************************************** ** Create a loop for the variables with the same weight ********************* ***************************************************************************** egen ls=rowmiss(electricity_depriv sanitation_depriv water_depriv floor_depriv cookingfuel_depriv asset_depriv) gen hh_missing=0 replace hh_missing=1 if educ_depriv==. | nutrihh==2 | attehh==2 | morthh==2 | (ls>0 & ls<.) foreach var in electricity_depriv sanitation_depriv water_depriv floor_depriv cookingfuel_depriv asset_depriv { gen w_`var'=1/18 if ls==0 } gen w_mortality5hh = 1/6 if morthh==1 & nutrihh==1 replace w_mortality5hh = 1/3 if morthh==1 & nutrihh==3 replace w_mortality5hh = 0 if morthh==3 & nutrihh==1 gen w_undernutritionhh = 1/6 if morthh==1 & nutrihh==1 replace w_undernutritionhh = 1/3 if morthh==3 & nutrihh==1 replace w_undernutritionhh = 0 if morthh==1 & nutrihh==3 gen w_child_noattendhh = 1/6 if attehh==1 | attehh==3 gen w_educ_depriv = 1/6 if educ_depriv<. ******************************************************************* ********* Define the weigthed deprivation g0* matrix **** ******************************************************************* foreach var in `varlist_pov' { gen wg0_`var' = `var'*w_`var' } ****************************************************************************** *********** Compute the frequency of missing values for indicator ************ ****************************************************************************** foreach var in `varlist_pov' { gen `var'_miss=1 if `var'==. replace `var'_miss=0 if `var'!=. } sum *_miss ******************************************************************************** ************* Define the (weighted) deprivation count vector "ci" ************ ******************************************************************************** egen ci=rsum(wg0_*) label variable ci "Deprivation Count" egen n_missing=rowmiss(wg0_*) label variable n_missing "Number of missing variables by individual" gen missing=(n_missing>0) label variable missing "Individual with missing variables" *** Check sample drop due to missing values tab missing ******************************************************************************* ***** Create de identification vector (poor/non poor) ************************* ***** and compute individual average of deprivation *************************** ******************************************************************************* forvalues x=1(1)10 { gen h_`x'0p=(ci>=`x'/10) replace h_`x'0p=. if missing==1 gen a_`x'0p=(ci) if h_`x'0p==1 replace a_`x'0p=. if missing==1 label var h_`x'0p "Condition of Multidimensional Poverty k=`x'" label var a_`x'0p "Individual Average deprivation k=`x'" } sum h_10p-a_100p [aw=weight] gen h_33p=(ci>=3.33/10) replace h_33p=. if missing==1 gen a_33p=(ci) if h_33p==1 replace a_33p=. if missing==1 label var h_33p "Condition of Multidimensional Poverty k=33.3" label var a_33p "Individual Average deprivation k=33.3" sum h_33p a_33p [aw=weight] ******************************************************************************** ******* Compute raw headcounts ****************************************** ******************************************************************************** foreach var in `varlist_pov' { gen `var'_raw=(`var') replace `var'_raw=. if missing==1 } su *_raw [iw=weight] ****************************************************************************** *********** Compute Censored headcount and censored headocunt **************** ****************************************************************************** ***** Please define in the first line your poverty cutoff, the example shows k=33.3 is 33.3% local k=1/3 foreach var in `varlist_pov' { *gen `var'_CH_`k'=(`var'==1 & h_`k'==1) *replace `var'_CH_`k'=. if missing==1 gen `var'_CH_33=(`var'==1 & h_33==1) replace `var'_CH_33=. if missing==1 } sum electricity_depriv_CH_33-educ_depriv_CH_33 [iw=weight] sum h_33 a_33 [iw=weight] *h = HC *a = intensity capture drop cedu chealth cls scalar drop _all gen cedu = (child_noattendhh_CH_33 * w_child_noattendhh) + (educ_depriv_CH_33 * w_educ_depriv) sum cedu [iw=weight] scalar mpi_edu=r(mean) gen chealth = (mortality5hh_CH_33 * w_mortality5hh) + (undernutritionhh_CH_33 * w_undernutritionhh) sum chealth [iw=weight] scalar mpi_health=r(mean) gen cls = (electricity_depriv_CH_33 * w_electricity_depriv) + (sanitation_depriv_CH_33 * w_sanitation_depriv) + (water_depriv_CH_33 * w_water_depriv) + (floor_depriv_CH_33 * w_floor_depriv) + (cookingfuel_depriv_CH_33 * w_cookingfuel_depriv) + (asset_depriv_CH_33 * w_asset_depriv) sum cls [iw=weight] scalar mpi_ls=r(mean) sum a_33p [iw=weight] scalar intensity = r(mean) sum h_33p [iw=weight] scalar headcount = r(mean) scalar mpi=headcount*intensity scalar headcount100=headcount*100 scalar intensity100=intensity*100 scalar edu_contrib = (mpi_edu/mpi)*100 scalar health_contrib = (mpi_health/mpi)*100 scalar ls_contrib = (mpi_ls/mpi)*100 capture drop uno gen uno=1 if h_33p<. sum uno [aw=weight] if h_33p<. scalar pop=r(sum_w) sum uno [aw=weight] if h_33p<. & ci>0 & ci<(1/3) scalar pop_vuln0=r(sum_w) sum uno [aw=weight] if h_33p<. & ci>=0.2 & ci<(1/3) scalar pop_vuln20=r(sum_w) sum uno [aw=weight] if h_33p<. & ci>=0.5 scalar pop_severe=r(sum_w) scalar vulnerable0=(pop_vuln0/pop)*100 scalar vulnerable20=(pop_vuln20/pop)*100 scalar severity=(pop_severe/pop)*100 * Sample size * HHs capture drop hh egen hh=group(cluster hhnum) sort age bys hh: gen n=_n gen nhh=1 if n==1 * Individuals capture drop uno gen uno=1 sum uno scalar ind_sample_tot=r(N) sum uno if h_33p<. scalar ind_sample_used=r(N) sum uno [w=weight] if h_33p<. scalar ind_sample_used_w=r(sum) sum nhh scalar hh_sample_tot=r(N) sum nhh if h_33p<. scalar hh_sample_used=r(N) sum nhh [w=weight] if h_33p<. scalar hh_sample_used_w=r(sum) * Inequality sum a_33p [aw=weight] scalar cv_ineq_poor = r(sd)/r(mean) sum ci [aw=weight] if h_33p<. scalar cv_ineq_hc = r(sd)/r(mean) sum ci [aw=weight] if h_33p<. & ci>0 scalar cv_ineq_positive = r(sd)/r(mean) * CONTRIBUTION OF EACH DIMENSION FOR THE VULNERABLE POEPLE foreach var in `varlist_pov' { gen `var'_CH_33vu=0 if h_33p<. & ci>=0.2 & ci<(1/3) replace `var'_CH_33vu=1 if `var'==1 & h_33p<. & ci>=0.2 & ci<(1/3) replace `var'_CH_33vu=. if missing==1 } gen ceduvu = (child_noattendhh_CH_33vu * w_child_noattendhh) + (educ_depriv_CH_33vu * w_educ_depriv) sum ceduvu [iw=weight] if h_33p<. & ci>=0.2 & ci<(1/3) scalar mpi_eduvu=r(mean) gen chealthvu = (mortality5hh_CH_33vu * w_mortality5hh) + (undernutritionhh_CH_33vu * w_undernutritionhh) sum chealthvu [iw=weight] if h_33p<. & ci>=0.2 & ci<(1/3) scalar mpi_healthvu=r(mean) gen clsvu = (asset_depriv_CH_33vu * w_asset_depriv) + (electricity_depriv_CH_33vu * w_electricity_depriv) + (sanitation_depriv_CH_33vu * w_sanitation_depriv) + (water_depriv_CH_33vu * w_water_depriv) + (floor_depriv_CH_33vu * w_floor_depriv) + (cookingfuel_depriv_CH_33vu * w_cookingfuel_depriv) sum clsvu [iw=weight] if h_33p<. & ci>=0.2 & ci<(1/3) scalar mpi_lsvu=r(mean) sum ci [iw=weight] if h_33p<. & ci>=0.2 & ci<(1/3) scalar headcountvu = r(mean) scalar headcountvu100=headcountvu*100 scalar edu_contribvu = (mpi_eduvu/headcountvu100)*10000 scalar health_contribvu = (mpi_healthvu/headcountvu100)*10000 scalar ls_contribvu = (mpi_lsvu/headcountvu100)*10000 scalar list mpi headcount100 intensity100 vulnerable0 vulnerable20 severity edu_contrib health_contrib ls_contrib edu_contribvu health_contribvu ls_contribvu cv_ineq_poor cv_ineq_positive cv_ineq_hc hh_sample_tot hh_sample_used hh_sample_used_w ind_sample_tot ind_sample_used ind_sample_used_w gen sample6y=1 if h_33p<. sort cluster hhnum *gen sample_all=1 if (sample6y==. & (nutrihh==1 | nutrihh==2 | nutrihh==3)) | sample6y==1 gen sample_all=1 sort cluster hhnum save "Morocco_MPI2_2011_final.dta", replace capture log close ******************** *** RE-WEIGHTING *** ******************** clear use "Morocco_MPI2_2011_final.dta", clear gen age_group=1 if age>=0 & age<=5 replace age_group=2 if age>=6 & age<=14 replace age_group=3 if age>=15 & age<=49 replace age_group=4 if age>=50 & age<. set more off scalar drop _all forvalues a=1(1)4 { forvalues s=0(1)1 { forvalues u=0(1)1 { sum sample_all [w=weight] if age_group==`a' & sex==`s' & urban==`u' scalar sample_`a'_`s'_`u' = r(sum_w) } } } *************************************************************************** **** MISSING IN THE 3 VARIABLES (we don't observe sex, age and urban) ***** *************************************************************************** sum sample_all [w=weight] if (sex==. & urb==. & age_g==.) | (sex<. & urb<. & age_g<.) scalar sample_mnm = r(sum_w) sum sample_all [w=weight] if (sex<. & urb<. & age_g<.) scalar sample_nm = r(sum_w) scalar ratio_all = sample_mnm / sample_nm forvalues a=1(1)4 { forvalues s=0(1)1 { forvalues u=0(1)1 { scalar sample_nm_`a'_`s'_`u' = ratio_all * sample_`a'_`s'_`u' } } } ************************************************************************************** **** MPI SAMPLE MISSING IN THE 3 VARIABLES (we don't observe sex, age and urban) ***** ************************************************************************************** * NEW MPI SAMPLE forvalues a=1(1)4 { forvalues s=0(1)1 { forvalues u=0(1)1 { sum sample_all [w=weight] if age_group==`a' & sex==`s' & urban==`u' & sample6y==1 scalar sample_`a'_`s'_`u'_6y = r(sum_w) } } } sum sample_all [w=weight] if sample6y==1 & ((sex==. & urb==. & age_g==.) | (sex<. & urb<. & age_g<.)) scalar sample_mnm_6y = r(sum_w) sum sample_all [w=weight] if (sex<. & urb<. & age_g<.) & sample6y==1 scalar sample_nm_6y = r(sum_w) scalar ratio_all_6y = sample_mnm_6y / sample_nm_6y forvalues a=1(1)4 { forvalues s=0(1)1 { forvalues u=0(1)1 { scalar sample_nm_`a'_`s'_`u'_6y = ratio_all_6y * sample_`a'_`s'_`u'_6y } } } ************************************************************************************** **** MISSING IN TWO VARIABLES AT A TIME (we only observe one: sex, age or urban) ***** ************************************************************************************** * ONLY OBSERVE SEX forvalues s = 0(1)1 { sum sample_all [w=weight] if sex==`s' & (sex<. & urb==. & age_g==.) scalar sample_m_`s's_onlysex = r(sum_w) sum sample6y [w=weight] if sex==`s' & (sex<. & urb==. & age_g==.) scalar sample_m_`s's_onlysex_6y = r(sum_w) } forvalues s = 0(1)1 { scalar samplenew_`s's = sample_nm_4_`s'_1 + sample_nm_4_`s'_0 + sample_nm_3_`s'_1 + sample_nm_3_`s'_0 + sample_nm_2_`s'_1 + sample_nm_2_`s'_0 + sample_nm_1_`s'_1 + sample_nm_1_`s'_0 scalar samplenew_`s's_onlysex = samplenew_`s's + sample_m_`s's_onlysex scalar samplenew_`s's_6y = sample_nm_4_`s'_1_6y + sample_nm_4_`s'_0_6y + sample_nm_3_`s'_1_6y + sample_nm_3_`s'_0_6y + sample_nm_2_`s'_1_6y + sample_nm_2_`s'_0_6y + sample_nm_1_`s'_1_6y + sample_nm_1_`s'_0_6y scalar samplenew_`s's_onlysex_6y = samplenew_`s's_6y + sample_m_`s's_onlysex_6y } forvalues s = 0(1)1 { scalar ratio_`s's_onlysex = samplenew_`s's_onlysex / samplenew_`s's scalar ratio_`s's_onlysex_6y = samplenew_`s's_onlysex_6y / samplenew_`s's_6y } forvalues a=1(1)4 { forvalues s=0(1)1 { forvalues u=0(1)1 { scalar sample_onlysex_`a'a_`s's_`u'u_all = sample_nm_`a'_`s'_`u' * ratio_`s's_onlysex scalar sample_onlysex_`a'a_`s's_`u'u_6y = sample_nm_`a'_`s'_`u'_6y * ratio_`s's_onlysex_6y } } } * ONLY OBSERVE AGE forvalues a = 1(1)4 { sum sample_all [w=weight] if age_g==`a' & (sex==. & urb==. & age_g<.) scalar sample_m_`a'a_onlyage = r(sum_w) sum sample6y [w=weight] if age_g==`a' & (sex==. & urb==. & age_g<.) scalar sample_m_`a'a_onlyage_6y = r(sum_w) } forvalues a = 1(1)4 { scalar samplenew_`a'a = sample_onlysex_`a'a_1s_1u_all + sample_onlysex_`a'a_1s_0u_all + sample_onlysex_`a'a_0s_1u_all + sample_onlysex_`a'a_0s_0u_all scalar samplenew_`a'a_onlyage = samplenew_`a'a + sample_m_`a'a_onlyage scalar samplenew_`a'a_6y = sample_onlysex_`a'a_1s_1u_6y + sample_onlysex_`a'a_1s_0u_6y + sample_onlysex_`a'a_0s_1u_6y + sample_onlysex_`a'a_0s_0u_6y scalar samplenew_`a'a_onlyage_6y = samplenew_`a'a_6y + sample_m_`a'a_onlyage_6y } forvalues a = 1(1)4 { scalar ratio_`a'a_onlyage = samplenew_`a'a_onlyage / samplenew_`a'a scalar ratio_`a'a_onlyage_6y = samplenew_`a'a_onlyage_6y / samplenew_`a'a_6y } forvalues a=1(1)4 { forvalues s=0(1)1 { forvalues u=0(1)1 { scalar sample_onlyage_`a'a_`s's_`u'u_all = sample_onlysex_`a'a_`s's_`u'u_all * ratio_`a'a_onlyage scalar sample_onlyage_`a'a_`s's_`u'u_6y = sample_onlysex_`a'a_`s's_`u'u_6y * ratio_`a'a_onlyage_6y } } } * ONLY OBSERVE URBAN forvalues u = 0(1)1 { sum sample_all [w=weight] if urban==`u' & (sex==. & urb<. & age_g==.) scalar sample_m_`u'u_onlyurb = r(sum_w) sum sample6y [w=weight] if urban==`u' & (sex==. & urb<. & age_g==.) scalar sample_m_`u'u_onlyurb_6y = r(sum_w) } forvalues u = 0(1)1 { scalar samplenew_`u'u = sample_onlyage_4a_1s_`u'u_all + sample_onlyage_4a_0s_`u'u_all + sample_onlyage_3a_1s_`u'u_all + sample_onlyage_3a_0s_`u'u_all + sample_onlyage_2a_1s_`u'u_all + sample_onlyage_2a_0s_`u'u_all + sample_onlyage_1a_1s_`u'u_all + sample_onlyage_1a_0s_`u'u_all scalar samplenew_`u'u_onlyurb = samplenew_`u'u + sample_m_`u'u_onlyurb scalar samplenew_`u'u_6y = sample_onlyage_4a_1s_`u'u_6y + sample_onlyage_4a_0s_`u'u_6y + sample_onlyage_3a_1s_`u'u_6y + sample_onlyage_3a_0s_`u'u_6y + sample_onlyage_2a_1s_`u'u_6y + sample_onlyage_2a_0s_`u'u_6y + sample_onlyage_1a_1s_`u'u_6y + sample_onlyage_1a_0s_`u'u_6y scalar samplenew_`u'u_onlyurb_6y = samplenew_`u'u_6y + sample_m_`u'u_onlyurb_6y } forvalues u = 0(1)1 { scalar ratio_`u'u_onlyurb = samplenew_`u'u_onlyurb / samplenew_`u'u scalar ratio_`u'u_onlyurb_6y = samplenew_`u'u_onlyurb_6y / samplenew_`u'u_6y } forvalues a=1(1)4 { forvalues s=0(1)1 { forvalues u=0(1)1 { scalar sample_onlyurb_`a'a_`s's_`u'u_all = sample_onlyage_`a'a_`s's_`u'u_all * ratio_`u'u_onlyurb scalar sample_onlyurb_`a'a_`s's_`u'u_6y = sample_onlyage_`a'a_`s's_`u'u_6y * ratio_`u'u_onlyurb_6y } } } *********************************************************************** **** MISSING IN ONE VARIABLE AT A TIME (either sex, age or urban) ***** *********************************************************************** * missing sex forvalues a=1(1)4 { forvalues u=0(1)1 { sum sample_all [w=weight] if age_group==`a' & urban==`u' & (sex==. & age_g<. & urban<.) scalar sample_m_`a'a_`u'u = r(sum_w) sum sample6y [w=weight] if age_group==`a' & urban==`u' & (sex==. & age_g<. & urban<.) scalar sample_m_`a'a_`u'u_6y = r(sum_w) } } * SEX MISSING: COLLAPSE THE 16 GROUPS INTO 8 GROUPS (AGE-URBAN) forvalues a=1(1)4 { forvalues u=0(1)1 { scalar samplenew_`a'a_`u'u = sample_onlyurb_`a'a_1s_`u'u_all + sample_onlyurb_`a'a_0s_`u'u_all scalar samplenew_`a'a_`u'u_sexm = samplenew_`a'a_`u'u + sample_m_`a'a_`u'u scalar samplenew_`a'a_`u'u_6y = sample_onlyurb_`a'a_1s_`u'u_6y + sample_onlyurb_`a'a_0s_`u'u_6y scalar samplenew_`a'a_`u'u_sexm_6y = samplenew_`a'a_`u'u_6y + sample_m_`a'a_`u'u_6y } } forvalues a=1(1)4 { forvalues u = 0(1)1 { scalar ratio_`a'a_`u'u = samplenew_`a'a_`u'u_sexm / samplenew_`a'a_`u'u scalar ratio_`a'a_`u'u_6y = samplenew_`a'a_`u'u_sexm_6y / samplenew_`a'a_`u'u_6y } } forvalues a=1(1)4 { forvalues s=0(1)1 { forvalues u=0(1)1 { scalar sample_sexmis_`a'a_`s's_`u'u_all = sample_onlyurb_`a'a_`s's_`u'u_all * ratio_`a'a_`u'u scalar sample_sexmis_`a'a_`s's_`u'u_6y = sample_onlyurb_`a'a_`s's_`u'u_6y * ratio_`a'a_`u'u_6y } } } * missing age forvalues s=0(1)1 { forvalues u=0(1)1 { sum sample_all [w=weight] if sex==`s' & urban==`u' & (sex<. & age_g==. & urban<.) scalar sample_m_`s's_`u'u = r(sum_w) sum sample6y [w=weight] if sex==`s' & urban==`u' & (sex<. & age_g==. & urban<.) scalar sample_m_`s's_`u'u_6y = r(sum_w) } } * AGE MISSING: COLLAPSE THE 16 GROUPS INTO 4 GROUPS (SEX-URBAN) forvalues s=0(1)1 { forvalues u=0(1)1 { scalar samplenew_`s's_`u'u = sample_sexmis_4a_`s's_`u'u_all + sample_sexmis_3a_`s's_`u'u_all + sample_sexmis_2a_`s's_`u'u_all + sample_sexmis_1a_`s's_`u'u_all scalar samplenew_`s's_`u'u_agem = samplenew_`s's_`u'u + sample_m_`s's_`u'u scalar samplenew_`s's_`u'u_6y = sample_sexmis_4a_`s's_`u'u_6y + sample_sexmis_3a_`s's_`u'u_6y + sample_sexmis_2a_`s's_`u'u_6y + sample_sexmis_1a_`s's_`u'u_6y scalar samplenew_`s's_`u'u_agem_6y = samplenew_`s's_`u'u_6y + sample_m_`s's_`u'u_6y } } forvalues s=0(1)1 { forvalues u = 0(1)1 { scalar ratio_`s's_`u'u = samplenew_`s's_`u'u_agem / samplenew_`s's_`u'u scalar ratio_`s's_`u'u_6y = samplenew_`s's_`u'u_agem_6y / samplenew_`s's_`u'u_6y } } forvalues a=1(1)4 { forvalues s=0(1)1 { forvalues u=0(1)1 { scalar sample_agemis_`a'a_`s's_`u'u_all = sample_sexmis_`a'a_`s's_`u'u_all * ratio_`s's_`u'u scalar sample_agemis_`a'a_`s's_`u'u_6y = sample_sexmis_`a'a_`s's_`u'u_6y * ratio_`s's_`u'u_6y } } } * missing urban forvalues a=1(1)4 { forvalues s=0(1)1 { sum sample_all [w=weight] if age_g==`a' & sex==`s' & (sex<. & age_g<. & urban==.) scalar sample_m_`a'a_`s's = r(sum_w) sum sample6y [w=weight] if age_g==`a' & sex==`s' & (sex<. & age_g<. & urban==.) scalar sample_m_`a'a_`s's_6y = r(sum_w) } } * URBAN MISSING: COLLAPSE THE 16 GROUPS INTO 8 GROUPS (AGE-SEX) forvalues a=1(1)4 { forvalues s=0(1)1 { scalar samplenew_`a'a_`s's = sample_agemis_`a'a_`s's_1u_all + sample_agemis_`a'a_`s's_0u_all scalar samplenew_`a'a_`s's_urbm = samplenew_`a'a_`s's + sample_m_`a'a_`s's scalar samplenew_`a'a_`s's_6y = sample_agemis_`a'a_`s's_1u_6y + sample_agemis_`a'a_`s's_0u_6y scalar samplenew_`a'a_`s's_urbm_6y = samplenew_`a'a_`s's_6y + sample_m_`a'a_`s's_6y } } forvalues a=1(1)4 { forvalues s = 0(1)1 { scalar ratio_`a'a_`s's = samplenew_`a'a_`s's_urbm / samplenew_`a'a_`s's scalar ratio_`a'a_`s's_6y = samplenew_`a'a_`s's_urbm_6y / samplenew_`a'a_`s's_6y } } forvalues a=1(1)4 { forvalues s=0(1)1 { forvalues u=0(1)1 { scalar sample_urbmis_`a'a_`s's_`u'u_all = sample_agemis_`a'a_`s's_`u'u_all * ratio_`a'a_`s's scalar sample_urbmis_`a'a_`s's_`u'u_6y = sample_agemis_`a'a_`s's_`u'u_6y * ratio_`a'a_`s's_6y } } } ********************************************************************** *** CORRECTING THE ORIGINAL WEIGHTS FOR EVERYONE IN THE MPI SAMPLE *** ********************************************************************** * COLLAPSE THE CORRECTED CELLS INTO DIFFERENT GROUPS ACCORDING TO THEIR MISSINGS TO CORRECT THE WEIGHTS OF THE OBSERVATIONS IN THE MPI SAMPLE WITH MISSINGS IN AGE, SEX AND OR URBAN * SEX, AGE AND URBAN MISSING scalar total_all = sample_urbmis_4a_1s_1u_all + sample_urbmis_4a_1s_0u_all + sample_urbmis_4a_0s_1u_all + sample_urbmis_4a_0s_0u_all + sample_urbmis_3a_1s_1u_all + sample_urbmis_3a_1s_0u_all + sample_urbmis_3a_0s_1u_all + sample_urbmis_3a_0s_0u_all + sample_urbmis_2a_1s_1u_all + sample_urbmis_2a_1s_0u_all + sample_urbmis_2a_0s_1u_all + sample_urbmis_2a_0s_0u_all + sample_urbmis_1a_1s_1u_all + sample_urbmis_1a_1s_0u_all + sample_urbmis_1a_0s_1u_all + sample_urbmis_1a_0s_0u_all scalar total_6y = sample_urbmis_4a_1s_1u_6y + sample_urbmis_4a_1s_0u_6y + sample_urbmis_4a_0s_1u_6y + sample_urbmis_4a_0s_0u_6y + sample_urbmis_3a_1s_1u_6y + sample_urbmis_3a_1s_0u_6y + sample_urbmis_3a_0s_1u_6y + sample_urbmis_3a_0s_0u_6y + sample_urbmis_2a_1s_1u_6y + sample_urbmis_2a_1s_0u_6y + sample_urbmis_2a_0s_1u_6y + sample_urbmis_2a_0s_0u_6y + sample_urbmis_1a_1s_1u_6y + sample_urbmis_1a_1s_0u_6y + sample_urbmis_1a_0s_1u_6y + sample_urbmis_1a_0s_0u_6y scalar ratio_total = total_all / total_6y * ONLY OBSERVE SEX forvalues s = 0(1)1 { scalar total_sex`s'_all = sample_urbmis_4a_`s's_1u_all + sample_urbmis_4a_`s's_0u_all + sample_urbmis_3a_`s's_1u_all + sample_urbmis_3a_`s's_0u_all + sample_urbmis_2a_`s's_1u_all + sample_urbmis_2a_`s's_0u_all + sample_urbmis_1a_`s's_1u_all + sample_urbmis_1a_`s's_0u_all scalar total_sex`s'_6y = sample_urbmis_4a_`s's_1u_6y + sample_urbmis_4a_`s's_0u_6y + sample_urbmis_3a_`s's_1u_6y + sample_urbmis_3a_`s's_0u_6y + sample_urbmis_2a_`s's_1u_6y + sample_urbmis_2a_`s's_0u_6y + sample_urbmis_1a_`s's_1u_6y + sample_urbmis_1a_`s's_0u_6y scalar ratio_total_sex`s' = total_sex`s'_all / total_sex`s'_6y } * ONLY OBSERVE AGE forvalues a = 1(1)4 { scalar total_age`a'_all = sample_urbmis_`a'a_1s_1u_all + sample_urbmis_`a'a_1s_0u_all + sample_urbmis_`a'a_0s_1u_all + sample_urbmis_`a'a_0s_0u_all scalar total_age`a'_6y = sample_urbmis_`a'a_1s_1u_6y + sample_urbmis_`a'a_1s_0u_6y + sample_urbmis_`a'a_0s_1u_6y + sample_urbmis_`a'a_0s_0u_6y scalar ratio_total_age`a' = total_age`a'_all / total_age`a'_6y } * ONLY OBSERVE URBAN forvalues u = 0(1)1 { scalar total_urb`u'_all = sample_urbmis_4a_1s_`u'u_all + sample_urbmis_4a_0s_`u'u_all + sample_urbmis_3a_1s_`u'u_all + sample_urbmis_3a_0s_`u'u_all + sample_urbmis_2a_1s_`u'u_all + sample_urbmis_2a_0s_`u'u_all + sample_urbmis_1a_1s_`u'u_all + sample_urbmis_1a_0s_`u'u_all scalar total_urb`u'_6y = sample_urbmis_4a_1s_`u'u_6y + sample_urbmis_4a_0s_`u'u_6y + sample_urbmis_3a_1s_`u'u_6y + sample_urbmis_3a_0s_`u'u_6y + sample_urbmis_2a_1s_`u'u_6y + sample_urbmis_2a_0s_`u'u_6y + sample_urbmis_1a_1s_`u'u_6y + sample_urbmis_1a_0s_`u'u_6y scalar ratio_total_urb`u' = total_urb`u'_all / total_urb`u'_6y } * SEX MISSING ONLY forvalues a = 1(1)4 { forvalues u = 0(1)1 { scalar total_sexmis_`a'a_`u'u_all = sample_urbmis_`a'a_1s_`u'u_all + sample_urbmis_`a'a_0s_`u'u_all scalar total_sexmis_`a'a_`u'u_6y = sample_urbmis_`a'a_1s_`u'u_6y + sample_urbmis_`a'a_0s_`u'u_6y scalar ratio_total_sexmis_`a'a_`u'u = total_sexmis_`a'a_`u'u_all / total_sexmis_`a'a_`u'u_6y } } * AGE MISSING ONLY forvalues s = 0(1)1 { forvalues u = 0(1)1 { scalar total_agemis_`s's_`u'u_all = sample_urbmis_4a_`s's_`u'u_all + sample_urbmis_3a_`s's_`u'u_all + sample_urbmis_2a_`s's_`u'u_all + sample_urbmis_1a_`s's_`u'u_all scalar total_agemis_`s's_`u'u_6y = sample_urbmis_4a_`s's_`u'u_6y + sample_urbmis_3a_`s's_`u'u_6y + sample_urbmis_2a_`s's_`u'u_6y + sample_urbmis_1a_`s's_`u'u_6y scalar ratio_total_agemis_`s's_`u'u = total_agemis_`s's_`u'u_all / total_agemis_`s's_`u'u_6y } } * URBAN MISSING ONLY forvalues a = 1(1)4 { forvalues s = 0(1)1 { scalar total_urbmis_`a'a_`s's_all = sample_urbmis_`a'a_`s's_1u_all + sample_urbmis_`a'a_`s's_0u_all scalar total_urbmis_`a'a_`s's_6y = sample_urbmis_`a'a_`s's_1u_6y + sample_urbmis_`a'a_`s's_0u_6y scalar ratio_total_urbmis_`a'a_`s's = total_urbmis_`a'a_`s's_all / total_urbmis_`a'a_`s's_6y } } * DEFINE THE RATIOS FOR NON-MISSING VALUES IN SEX, AGE AND URBAN forvalues a=1(1)4 { forvalues s=0(1)1 { forvalues u=0(1)1 { scalar sample_all_`a'_`s'_`u'_w = sample_urbmis_`a'a_`s's_`u'u_all / sample_urbmis_`a'a_`s's_`u'u_6y } } } capture drop weight_w gen weight_w = weight if sample6y==1 *& age_group<. & sex<. & urban<. forvalues a=1(1)4 { forvalues s=0(1)1 { forvalues u=0(1)1 { replace weight_w = weight * sample_all_`a'_`s'_`u'_w if age_group==`a' & sex==`s' & urban==`u' & sample6y==1 } } } replace weight_w = weight * ratio_total if sample6y==1 & age_group==. & sex==. & urban==. forvalues s=0(1)1 { replace weight_w = weight * ratio_total_sex`s' if sample6y==1 & age_group==. & sex==`s' & urban==. } forvalues a=1(1)4 { replace weight_w = weight * ratio_total_age`a' if sample6y==1 & age_group==`a' & sex==. & urban==. } forvalues u=0(1)1 { replace weight_w = weight * ratio_total_urb`u' if sample6y==1 & age_group==. & sex==. & urban==`u' } forvalues a = 1(1)4 { forvalues u = 0(1)1 { replace weight_w = weight * ratio_total_sexmis_`a'a_`u'u if sample6y==1 & age_group==`a' & sex==. & urban==`u' } } forvalues s = 0(1)1 { forvalues u = 0(1)1 { replace weight_w = weight * ratio_total_agemis_`s's_`u'u if sample6y==1 & age_group==. & sex==`s' & urban==`u' } } forvalues a = 1(1)4 { forvalues s = 0(1)1 { replace weight_w = weight * ratio_total_urbmis_`a'a_`s's if sample6y==1 & age_group==`a' & sex==`s' & urban==. } } sort cluster hhnum save "Morocco_MPI2_2011_final_w.dta", replace * OPEN DATA WITH NEW WEIGHT FOR HH USED IN NEW MPI (CORRECTS FOR THE EXCLUSION OF HHs WITHOUT ELIGIBLE POP) ** ADAPTED BY CECILIA ON AUGUST 5 2013 ** ** Morocco 2011 ** clear set more off set maxvar 10000 set mem 500m cap log close *** Replace here your path to the dataset*** cd "C:\Users\cecilia.calderon\Documents\HDRO_MCC\MPI\MPI_new calculations\Morocco 2011_PAPFAM\" *** Replace here the name of your dataset*** capture log close log using "M0_dofile_Morocco2011_MPI2_w.log", text replace use "Morocco_MPI2_2011_final_w.dta", clear capture drop ls-uno ********************************************************************************* ******* Define the deprivation matrix **************************************** ********************************************************************************* *** The dataset can be interpreted as the matrix of achivemnts *** We will now crate the deprivation matrix based on the indicator definition; and deprivation cut-off defined by you *** during the last working session on the normative Issues in Multidimensional Poverty Measure *** In order to do this, we will generate a new variable for each indicator contained in our measure *** This will identify with 0 individuals or households who are not deprived in the specific indicator *** and identify with 1 individual deprived in the specific indicator. *** Note that you will need to replace with dot "." if the information is missing or inconsistent. *** We will assess later the frequency of missing values. ** DEPRIVED IN DRINKING WATER ** (the individual -HH- is considered deprived in drinking water is: unprotected well, spring, river/lake/pond or other) /*lookfor water codebook b2q12, tab(20) gen d_dwater=(b2q12==5 | b2q12==6 | b2q12==7 | b2q12==8) replace d_dwater=. if b2q12==. tab b2q12 d_dwater [aw=weight], miss label variable d_dwater "Deprived in drinking water"ic*/ ** Please follow the same logic for all indicators. ** Note that for advance indicator you may have to use more complex algorithms ***************************************************************************** ******** Create a local variable with all your indicators ********* ***************************************************************************** local varlist_pov electricity_depriv sanitation_depriv water_depriv floor_depriv cookingfuel_depriv asset_depriv educ_depriv child_noattendhh undernutritionhh mortality5hh ***************************************************************************** **** Define the weights ***************************** ***************************************************************************** ** Create a loop for the variables with the same weight ********************* ***************************************************************************** egen ls=rowmiss(electricity_depriv sanitation_depriv water_depriv floor_depriv cookingfuel_depriv asset_depriv) gen hh_missing=0 replace hh_missing=1 if educ_depriv==. | nutrihh==2 | attehh==2 | morthh==2 | (ls>0 & ls<.) foreach var in electricity_depriv sanitation_depriv water_depriv floor_depriv cookingfuel_depriv asset_depriv { gen w_`var'=1/18 if ls==0 } gen w_mortality5hh = 1/6 if morthh==1 & nutrihh==1 replace w_mortality5hh = 1/3 if morthh==1 & nutrihh==3 replace w_mortality5hh = 0 if morthh==3 & nutrihh==1 gen w_undernutritionhh = 1/6 if morthh==1 & nutrihh==1 replace w_undernutritionhh = 1/3 if morthh==3 & nutrihh==1 replace w_undernutritionhh = 0 if morthh==1 & nutrihh==3 gen w_child_noattendhh = 1/6 if attehh==1 | attehh==3 gen w_educ_depriv = 1/6 if educ_depriv<. ******************************************************************* ********* Define the weigthed deprivation g0* matrix **** ******************************************************************* foreach var in `varlist_pov' { gen wg0_`var' = `var'*w_`var' } ****************************************************************************** *********** Compute the frequency of missing values for indicator ************ ****************************************************************************** foreach var in `varlist_pov' { gen `var'_miss=1 if `var'==. replace `var'_miss=0 if `var'!=. } sum *_miss ******************************************************************************** ************* Define the (weighted) deprivation count vector "ci" ************ ******************************************************************************** egen ci=rsum(wg0_*) label variable ci "Deprivation Count" egen n_missing=rowmiss(wg0_*) label variable n_missing "Number of missing variables by individual" gen missing=(n_missing>0) label variable missing "Individual with missing variables" *** Check sample drop due to missing values tab missing ******************************************************************************* ***** Create de identification vector (poor/non poor) ************************* ***** and compute individual average of deprivation *************************** ******************************************************************************* forvalues x=1(1)10 { gen h_`x'0p=(ci>=`x'/10) replace h_`x'0p=. if missing==1 gen a_`x'0p=(ci) if h_`x'0p==1 replace a_`x'0p=. if missing==1 label var h_`x'0p "Condition of Multidimensional Poverty k=`x'" label var a_`x'0p "Individual Average deprivation k=`x'" } sum h_10p-a_100p [aw=weight_w] gen h_33p=(ci>=3.33/10) replace h_33p=. if missing==1 gen a_33p=(ci) if h_33p==1 replace a_33p=. if missing==1 label var h_33p "Condition of Multidimensional Poverty k=33.3" label var a_33p "Individual Average deprivation k=33.3" sum h_33p a_33p [aw=weight_w] ******************************************************************************** ******* Compute raw headcounts ****************************************** ******************************************************************************** foreach var in `varlist_pov' { gen `var'_raw=(`var') replace `var'_raw=. if missing==1 } su *_raw [iw=weight_w] ****************************************************************************** *********** Compute Censored headcount and censored headocunt **************** ****************************************************************************** ***** Please define in the first line your poverty cutoff, the example shows k=33.3 is 33.3% local k=1/3 foreach var in `varlist_pov' { *gen `var'_CH_`k'=(`var'==1 & h_`k'==1) *replace `var'_CH_`k'=. if missing==1 gen `var'_CH_33=(`var'==1 & h_33==1) replace `var'_CH_33=. if missing==1 } sum electricity_depriv_CH_33-educ_depriv_CH_33 [iw=weight_w] sum h_33 a_33 [iw=weight_w] *h = HC *a = intensity capture drop cedu chealth cls scalar drop _all gen cedu = (child_noattendhh_CH_33 * w_child_noattendhh) + (educ_depriv_CH_33 * w_educ_depriv) sum cedu [iw=weight_w] scalar mpi_edu=r(mean) gen chealth = (mortality5hh_CH_33 * w_mortality5hh) + (undernutritionhh_CH_33 * w_undernutritionhh) sum chealth [iw=weight_w] scalar mpi_health=r(mean) gen cls = (electricity_depriv_CH_33 * w_electricity_depriv) + (sanitation_depriv_CH_33 * w_sanitation_depriv) + (water_depriv_CH_33 * w_water_depriv) + (floor_depriv_CH_33 * w_floor_depriv) + (cookingfuel_depriv_CH_33 * w_cookingfuel_depriv) + (asset_depriv_CH_33 * w_asset_depriv) sum cls [iw=weight_w] scalar mpi_ls=r(mean) sum a_33p [iw=weight_w] scalar intensity = r(mean) sum h_33p [iw=weight_w] scalar headcount = r(mean) scalar mpi=headcount*intensity scalar headcount100=headcount*100 scalar intensity100=intensity*100 scalar edu_contrib = (mpi_edu/mpi)*100 scalar health_contrib = (mpi_health/mpi)*100 scalar ls_contrib = (mpi_ls/mpi)*100 capture drop uno gen uno=1 if h_33p<. sum uno [aw=weight_w] if h_33p<. scalar pop=r(sum_w) sum uno [aw=weight_w] if h_33p<. & ci>0 & ci<(1/3) scalar pop_vuln0=r(sum_w) sum uno [aw=weight_w] if h_33p<. & ci>=0.2 & ci<(1/3) scalar pop_vuln20=r(sum_w) sum uno [aw=weight_w] if h_33p<. & ci>=0.5 scalar pop_severe=r(sum_w) scalar vulnerable0=(pop_vuln0/pop)*100 scalar vulnerable20=(pop_vuln20/pop)*100 scalar severity=(pop_severe/pop)*100 * Sample size * HHs capture drop hh egen hh=group(cluster hhnum) sort age bys hh: gen n=_n gen nhh=1 if n==1 * Individuals capture drop uno gen uno=1 sum uno scalar ind_sample_tot=r(N) sum uno if h_33p<. scalar ind_sample_used=r(N) sum uno [w=weight_w] if h_33p<. scalar ind_sample_used_w=r(sum) sum nhh scalar hh_sample_tot=r(N) sum nhh if h_33p<. scalar hh_sample_used=r(N) sort cluster hhnum sum nhh [w=weight_w] if h_33p<. scalar hh_sample_used_w=r(sum) * Inequality sum a_33p [aw=weight_w] scalar cv_ineq_poor = r(sd)/r(mean) sum ci [aw=weight_w] if h_33p<. scalar cv_ineq_hc = r(sd)/r(mean) sum ci [aw=weight_w] if h_33p<. & ci>0 scalar cv_ineq_positive = r(sd)/r(mean) * CONTRIBUTION OF EACH DIMENSION FOR THE VULNERABLE POEPLE capture drop *vu foreach var in `varlist_pov' { gen `var'_CH_33vu=0 if h_33p<. & ci>=0.2 & ci<(1/3) replace `var'_CH_33vu=1 if `var'==1 & h_33p<. & ci>=0.2 & ci<(1/3) replace `var'_CH_33vu=. if missing==1 } gen ceduvu = (child_noattendhh_CH_33vu * w_child_noattendhh) + (educ_depriv_CH_33vu * w_educ_depriv) sum ceduvu [iw=weight_w] if h_33p<. & ci>=0.2 & ci<(1/3) scalar mpi_eduvu=r(mean) gen chealthvu = (mortality5hh_CH_33vu * w_mortality5hh) + (undernutritionhh_CH_33vu * w_undernutritionhh) sum chealthvu [iw=weight_w] if h_33p<. & ci>=0.2 & ci<(1/3) scalar mpi_healthvu=r(mean) gen clsvu = (asset_depriv_CH_33vu * w_asset_depriv) + (electricity_depriv_CH_33vu * w_electricity_depriv) + (sanitation_depriv_CH_33vu * w_sanitation_depriv) + (water_depriv_CH_33vu * w_water_depriv) + (floor_depriv_CH_33vu * w_floor_depriv) + (cookingfuel_depriv_CH_33vu * w_cookingfuel_depriv) sum clsvu [iw=weight_w] if h_33p<. & ci>=0.2 & ci<(1/3) scalar mpi_lsvu=r(mean) sum ci [iw=weight_w] if h_33p<. & ci>=0.2 & ci<(1/3) scalar headcountvu = r(mean) scalar headcountvu100=headcountvu*100 scalar edu_contribvu = (mpi_eduvu/headcountvu100)*10000 scalar health_contribvu = (mpi_healthvu/headcountvu100)*10000 scalar ls_contribvu = (mpi_lsvu/headcountvu100)*10000 * CONTRIBUTION OF EACH DIMENSION FOR THE VULNERABLE + POOR POEPLE (ci >= 0.2) capture drop *vupo foreach var in `varlist_pov' { gen `var'_CH_33vupo=0 if h_33p<. & ci>=0.2 & ci<. replace `var'_CH_33vupo=1 if `var'==1 & h_33p<. & ci>=0.2 & ci<. replace `var'_CH_33vupo=. if missing==1 } gen ceduvupo = (child_noattendhh_CH_33vupo * w_child_noattendhh) + (educ_depriv_CH_33vupo * w_educ_depriv) sum ceduvupo [iw=weight_w] if h_33p<. & ci>=0.2 & ci<. scalar mpi_eduvupo=r(mean) gen chealthvupo = (mortality5hh_CH_33vupo * w_mortality5hh) + (undernutritionhh_CH_33vupo * w_undernutritionhh) sum chealthvupo [iw=weight_w] if h_33p<. & ci>=0.2 & ci<. scalar mpi_healthvupo=r(mean) gen clsvupo = (asset_depriv_CH_33vupo * w_asset_depriv) + (electricity_depriv_CH_33vupo * w_electricity_depriv) + (sanitation_depriv_CH_33vupo * w_sanitation_depriv) + (water_depriv_CH_33vupo * w_water_depriv) + (floor_depriv_CH_33vupo * w_floor_depriv) + (cookingfuel_depriv_CH_33vupo * w_cookingfuel_depriv) sum clsvupo [iw=weight_w] if h_33p<. & ci>=0.2 & ci<. scalar mpi_lsvupo=r(mean) sum ci [iw=weight_w] if h_33p<. & ci>=0.2 & ci<. scalar headcountvupo = r(mean) scalar headcountvupo100=headcountvupo*100 scalar edu_contribvupo = (mpi_eduvupo/headcountvupo100)*10000 scalar health_contribvupo = (mpi_healthvupo/headcountvupo100)*10000 scalar ls_contribvupo = (mpi_lsvupo/headcountvupo100)*10000 scalar list mpi headcount100 intensity100 vulnerable0 vulnerable20 severity edu_contrib health_contrib ls_contrib edu_contribvu health_contribvu ls_contribvu edu_contribvupo health_contribvupo ls_contribvupo cv_ineq_poor cv_ineq_positive cv_ineq_hc hh_sample_tot hh_sample_used hh_sample_used_w ind_sample_tot ind_sample_used ind_sample_used_w sum sample_all [w=weight] scalar sall = r(sum) sum sample6y [w=weight_w] scalar smpi = r(sum) scalar list sall smpi ************************************ ** ALWAYS CHECK THAT sall = smpi ** ************************************