Use of data from IPUMS PMA is subject to conditions including that users should cite the data appropriately. Use command `ipums_conditions()` for more details.
#read in spatial datalibrary(sf)
Linking to GEOS 3.13.1, GDAL 3.10.2, PROJ 9.5.1; sf_use_s2() is TRUE
UG_PMA_GPS<-read_sf("C:/Users/Rebecca/Downloads/PMA_UG_GPS_v2_06July2022/UGANDA/PMA_UG_GPS_v2_06July2022.csv")#read in boundary dataUG_boundary<-read_sf("C:/Users/Rebecca/Downloads/geoug/geoug.shp")UG_boundary_4<-read_sf("C:/Users/Rebecca/Downloads/geouggen/geouggen.shp")UG_sub_boundary<-read_sf("C:/Users/Rebecca/Downloads/uganda-adm-boundaries/UGANDA BOUNDARIES SHAPEFILES AS OF 17 08 2018/COUNTIES_2018_UTM_36N.shp")pmaug2022<-pmauglong#%>%#filter(YEAR==2021)UG_PMA_GPS_2022<-UG_PMA_GPS#%>%#filter(PMAYEAR==2021)UG_PMA_GPS_2022<-UG_PMA_GPS%>%rename('EAID'='EA_ID')pmaug2022wgps<-merge(pmaug2022, UG_PMA_GPS_2022, by=c("EAID"))
#marital status pmaug2022wgps<-pmaug2022wgps%>%mutate(MARSTAT=as.factor(MARSTAT))%>%mutate(maritalstatus=recode(MARSTAT, '10'="never married" ,'20'="married or living together", '21'="currently married", '22'="currently living with partner", '31'="formerly in union",'32'='widow or widower',.default =NA_character_))tabyl(pmaug2022wgps, maritalstatus)
maritalstatus n percent valid_percent
never married 3506 0.2472845253 0.24735431
currently married 3416 0.2409366624 0.24100466
currently living with partner 4980 0.3512484130 0.35134754
formerly in union 1947 0.1373254338 0.13736419
widow or widower 325 0.0229228382 0.02292931
<NA> 4 0.0002821272 NA
#age-grouppmaug2022wgps<-pmaug2022wgps %>%mutate(agegroup =case_when( AGE >=15& AGE <=19~"15-19", AGE >=20& AGE <=24~"20-24", AGE >=25& AGE <=29~"25-29", AGE >=30& AGE <=34~"30-34", AGE >=35& AGE <=39~"35-39", AGE >=40& AGE <=44~"40-44", AGE >=45& AGE <=49~"45-49" ))pmaug2022wgps$age_z_score <-scale(pmaug2022wgps$AGE)pmaug2022wgps<-pmaug2022wgps%>%filter(BIRTHEVENT<90)pmaug2022wgps<-pmaug2022wgps %>%mutate(AGE=as.numeric(AGE))pmaug2022wgps<-pmaug2022wgps %>%mutate(URBAN=as.factor(URBAN))#contraceptive usepmaug2022wgps<-pmaug2022wgps%>%mutate(MCP=as.factor(MCP))%>%mutate(usingmoderncon=recode(MCP, '1'="yes" ,'0'="no",.default =NA_character_))tabyl(pmaug2022wgps, usingmoderncon)
usingmoderncon n percent valid_percent
no 9304 0.65645947 0.6662847
yes 4660 0.32879419 0.3337153
<NA> 209 0.01474635 NA
educationlevel n percent valid_percent
none 842 0.0594087349 0.05941712
primary/middle school 7902 0.5575389826 0.55761767
secondary/post-primary 4268 0.3011359627 0.30117846
tertiary/ post-secondary 1159 0.0817752064 0.08178675
<NA> 2 0.0001411134 NA
#collapse marital status variablepmaug2022wgps<-pmaug2022wgps%>%mutate(maritalcombined=recode(maritalstatus, 'formerly in union'='not in a union' ,'never married'="not in a union", 'widow or widower'="not in a union", 'currently married'="in a union", 'currently living with partner'="in a union"))#make index: exercise of choicelibrary(janitor)pmaug2022wgps <- pmaug2022wgps %>%mutate(startstop =case_when( STARTKIDDEC ==1| PTRDISCKIDSTOPWILL==1~'1', STARTKIDDEC ==2| PTRDISCKIDSTOPWILL==2~'2', STARTKIDDEC ==3| PTRDISCKIDSTOPWILL==3~'3', STARTKIDDEC ==4| PTRDISCKIDSTOPWILL==4~'4', STARTKIDDEC ==5| PTRDISCKIDSTOPWILL==5~'5' ))tabyl(pmaug2022wgps$startstop)
pmaug2022wgps <- pmaug2022wgps %>%mutate(water_cat_piped =as.integer(water_cat =="piped"),water_cat_public_tap =as.integer(water_cat =="public_tap"),water_cat_improved_nonpiped =as.integer(water_cat =="improved_nonpiped"),water_cat_improved_packaged =as.integer(water_cat =="improved_packaged"),water_cat_unimproved =as.integer(water_cat =="unimproved"),water_cat_unimproved_vendor =as.integer(water_cat =="unimproved_vendor"),water_cat_other =as.integer(water_cat =="other") )#household assets#restricted to what IPUMS's SCORE description names: radios, televisions,#bicycles, furniture. mobphone/motorcycle/electric/car/fridge/hhphone/#cassette/clock/drawncart are still created here (harmless, may be useful#elsewhere) but excluded from indicator_vars below since they aren't named#in the description.pmaug2022wgps <- pmaug2022wgps %>%mutate(radio =as.integer(RADIO ==1),tv =as.integer(TV ==1),mobphone =as.integer(MOBPHONE ==1),motorcycle =as.integer(MOTORCYCL ==1),electric =as.integer(ELECTRC ==1),bike =as.integer(BIKE ==1),bed =as.integer(BED ==1),cabinet =as.integer(CABINET ==1),chair =as.integer(CHAIR ==1),sofa =as.integer(SOFA ==1),table_own =as.integer(TABLE ==1),car =as.integer(CAR ==1),fridge =as.integer(FRIDGE ==1),hhphone =as.integer(HHPHONE ==1),cassette =as.integer(CASSETTE ==1),clock =as.integer(CLOCK ==1),drawncart =as.integer(DRAWNCART ==1),livestockown =as.integer(LIVESTOCKOWN ==1) )tabyl(pmaug2022wgps, electric)
electric n percent
0 7404 0.5224017
1 6769 0.4775983
tabyl(pmaug2022wgps, bike)
bike n percent
0 9920 0.6999224
1 4253 0.3000776
#livestock counts#restricted to what IPUMS's SCORE description names: chickens, sheep,#goats, horses/camels, cows/bulls, local cattle. PIGNUM and#OTHERLIVESTOCKNUM are excluded — not named in the description.livestock_vars <-c("CHICKENNUM", "SHEEPNUM", "GOATNUM", "HORSENUM","EXOCATTLENUM", "LOCALCATTLENUM")pmaug2022wgps <- pmaug2022wgps %>%mutate(across(all_of(livestock_vars),~if_else(.x >=99990, NA_real_, as.numeric(.x))))#households that own no livestock (LIVESTOCKOWN == 0) were not asked the#counts and are coded NIU; set their counts to 0 rather than imputing thempmaug2022wgps <- pmaug2022wgps %>%mutate(across(all_of(livestock_vars),~if_else(is.na(.x) & LIVESTOCKOWN ==0, 0, .x)))#household-level PCA, split by urban/ruraldf_hh <- pmaug2022wgps %>%distinct(HHID, YEAR, .keep_all =TRUE) %>%mutate(urban_f =as_factor(URBAN)) %>%filter(URBAN %in%c(0, 1))#indicator_vars restricted to exactly what IPUMS's SCORE description#names: floor/wall/roof materials, water source, toilet facility, radio,#television, bicycle, furniture (bed/cabinet/chair/sofa/table), and the#six named livestock categories.indicator_vars <-c(grep("^floor_cat_[a-z]|^wall_cat_[a-z]|^roof_cat_[a-z]|^water_cat_[a-z]|^toilet_cat_[a-z]",names(df_hh), value =TRUE),"radio", "tv", "bike","bed", "cabinet", "chair", "sofa", "table_own", livestock_vars)#check remaining missingness before stratum-mean imputationcolSums(is.na(df_hh[indicator_vars]))
rural_pca_imputed <-run_wealth_pca_imputed(rural_hh, indicator_vars)#check PCA sign orientation matches across strata before combining#(using electric here as the check variable, even though electric is#no longer part of indicator_vars, since it's still a reliable,#unambiguous wealth marker for validating orientation)cor_urban_check <-cor(urban_hh$electric, urban_pca_imputed$scores)cor_rural_check <-cor(rural_hh$electric, rural_pca_imputed$scores)cor_urban_check
The following objects are masked from 'package:tidyr':
expand, pack, unpack
Registered S3 method overwritten by 'lme4':
method from
na.action.merMod car
# relationship with urban status and summary score: controlling for year and a random effect for individual modelbiv <-lmer(summary_score_av ~factor(URBAN)+factor(YEAR)+ (1|FQINSTID), data = individualandcluster)modelsummary( modelbiv,slope ="b",stars =TRUE,title ="Bivariate relationship between urban/ rural status and pregnancy decision-makiong",gof_map =list(list(raw ="nobs", clean ="N", fmt =0)))
Bivariate relationship between urban/ rural status and pregnancy decision-makiong
(1)
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
(Intercept)
3.879***
(0.014)
factor(URBAN)1
0.070***
(0.017)
factor(YEAR)2021
0.061***
(0.016)
factor(YEAR)2022
0.015
(0.016)
SD (Intercept FQINSTID)
0.436
SD (Observations)
0.659
N
12150
#add a random effect for clustermodelbivwithcluster <-lmer(summary_score_av ~factor(URBAN)+factor(YEAR)+ (1|EAID)+ (1|FQINSTID), data = individualandcluster)modelsummary( modelbivwithcluster,slope ="b",stars =TRUE,title ="Relationship between urban/ rural status and pregnancy decision-making",gof_map =list(list(raw ="nobs", clean ="N", fmt =0)))
Relationship between urban/ rural status and pregnancy decision-making
(1)
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
(Intercept)
3.896***
(0.038)
factor(URBAN)1
0.089
(0.060)
factor(YEAR)2021
0.040**
(0.015)
factor(YEAR)2022
-0.003
(0.016)
SD (Intercept FQINSTID)
0.287
SD (Intercept EAID)
0.331
SD (Observations)
0.658
N
12150
Note: adding a random effect for cluster renders urban as insignificant when controlling for year in addition to a random effect for individual.
However, if we build a model that only includes a random effect for individual, not for cluster, urban has a significant and negative on pregnancy decision-making, so the suppression by wealth is happening here.
#full model without the cluster random effect library(lme4)modelmulti <-lmer(summary_score_av ~BIRTHEVENT + educationlevel + agegroup+ maritalcombined+factor(MCP)+factor(URBAN)+factor(WEALTHQ)+factor(YEAR)+ (1|FQINSTID), data = individualandcluster)modelsummary( modelmulti,slope ="b",stars =TRUE,title ="Relationship between urban/ rural status and pregnancy decision-making, individual random effect only",gof_map =list(list(raw ="nobs", clean ="N", fmt =0)))
Relationship between urban/ rural status and pregnancy decision-making, individual random effect only
(1)
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
(Intercept)
3.708***
(0.038)
BIRTHEVENT
-0.014**
(0.005)
educationlevelprimary/middle school
-0.007
(0.033)
educationlevelsecondary/post-primary
0.210***
(0.036)
educationleveltertiary/ post-secondary
0.263***
(0.044)
agegroup20-24
-0.017
(0.024)
agegroup25-29
0.005
(0.028)
agegroup30-34
0.047
(0.033)
agegroup35-39
-0.001
(0.038)
agegroup40-44
-0.032
(0.043)
agegroup45-49
-0.029
(0.046)
maritalcombinedin a union
-0.052**
(0.018)
factor(MCP)1
0.105***
(0.016)
factor(URBAN)1
-0.096***
(0.018)
factor(WEALTHQ)2
0.136***
(0.023)
factor(WEALTHQ)3
0.222***
(0.024)
factor(WEALTHQ)4
0.242***
(0.026)
factor(WEALTHQ)5
0.299***
(0.028)
factor(YEAR)2021
0.056***
(0.016)
factor(YEAR)2022
0.026
(0.016)
SD (Intercept FQINSTID)
0.392
SD (Observations)
0.658
N
12150
#full model with the cluster random effectmodelmulti_EAID <-lmer(summary_score_av ~ BIRTHEVENT + educationlevel + agegroup + maritalcombined +factor(MCP) +factor(URBAN) +factor(WEALTHQ) +factor(YEAR) + (1| FQINSTID) + (1| EAID),data = individualandcluster)modelsummary( modelmulti_EAID,stars =TRUE,title ="Relationship between urban/rural status and pregnancy decision-making (IPUMS wealth) with random effect for EAID",gof_map =list(list(raw ="nobs", clean ="N", fmt =0)))
Relationship between urban/rural status and pregnancy decision-making (IPUMS wealth) with random effect for EAID
(1)
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
(Intercept)
3.733***
(0.051)
BIRTHEVENT
-0.018***
(0.005)
educationlevelprimary/middle school
0.078*
(0.033)
educationlevelsecondary/post-primary
0.269***
(0.036)
educationleveltertiary/ post-secondary
0.338***
(0.043)
agegroup20-24
-0.016
(0.022)
agegroup25-29
0.011
(0.026)
agegroup30-34
0.057+
(0.030)
agegroup35-39
0.026
(0.034)
agegroup40-44
-0.010
(0.039)
agegroup45-49
-0.004
(0.042)
maritalcombinedin a union
-0.037*
(0.017)
factor(MCP)1
0.109***
(0.015)
factor(URBAN)1
-0.042
(0.056)
factor(WEALTHQ)2
0.051*
(0.026)
factor(WEALTHQ)3
0.098***
(0.027)
factor(WEALTHQ)4
0.114***
(0.029)
factor(WEALTHQ)5
0.145***
(0.032)
factor(YEAR)2021
0.037*
(0.015)
factor(YEAR)2022
0.004
(0.016)
SD (Intercept FQINSTID)
0.254
SD (Intercept EAID)
0.304
SD (Observations)
0.658
N
12150
Now if we run this with the PCA-derived measure of wealth, urban is not significant.
#run this with the PCA derived measure for wealthindividualandcluster <- individualandcluster %>%left_join(wealth_stratified_imputed %>%select(HHID, YEAR, score_z, wealthq_stratified_imputed),by =c("HHID", "YEAR"))modelmulti_pca <-lmer(summary_score_av ~ BIRTHEVENT + educationlevel + agegroup + maritalcombined +factor(MCP) +factor(URBAN) + wealthq_stratified_imputed +factor(YEAR) + (1| FQINSTID),data = individualandcluster)modelsummary( modelmulti_pca,stars =TRUE,title ="Relationship between urban/rural status and pregnancy decision-making (PCA-derived wealth)",gof_map =list(list(raw ="nobs", clean ="N", fmt =0)))
Relationship between urban/rural status and pregnancy decision-making (PCA-derived wealth)
(1)
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
(Intercept)
3.690***
(0.038)
BIRTHEVENT
-0.015**
(0.005)
educationlevelprimary/middle school
-0.004
(0.033)
educationlevelsecondary/post-primary
0.219***
(0.036)
educationleveltertiary/ post-secondary
0.266***
(0.044)
agegroup20-24
-0.017
(0.024)
agegroup25-29
0.007
(0.028)
agegroup30-34
0.051
(0.033)
agegroup35-39
0.005
(0.038)
agegroup40-44
-0.028
(0.043)
agegroup45-49
-0.024
(0.046)
maritalcombinedin a union
-0.052**
(0.018)
factor(MCP)1
0.107***
(0.016)
factor(URBAN)1
-0.017
(0.017)
wealthq_stratified_imputedSecond
0.132***
(0.024)
wealthq_stratified_imputedMiddle
0.195***
(0.024)
wealthq_stratified_imputedFourth
0.226***
(0.025)
wealthq_stratified_imputedHighest
0.267***
(0.026)
factor(YEAR)2021
0.058***
(0.016)
factor(YEAR)2022
0.016
(0.016)
SD (Intercept FQINSTID)
0.395
SD (Observations)
0.658
N
12150
Now when we add a random effect for cluster, urban remains non-significant.
modelmulti_pca_EAID <-lmer(summary_score_av ~ BIRTHEVENT + educationlevel + agegroup + maritalcombined +factor(MCP) +factor(URBAN) + wealthq_stratified_imputed +factor(YEAR) + (1| FQINSTID)+ (1|EAID),data = individualandcluster)modelsummary( modelmulti_pca_EAID,stars =TRUE,title ="Relationship between urban/rural status and pregnancy decision-making (PCA-derived wealth) with random effect for EAID",gof_map =list(list(raw ="nobs", clean ="N", fmt =0)))
Relationship between urban/rural status and pregnancy decision-making (PCA-derived wealth) with random effect for EAID
(1)
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
(Intercept)
3.693***
(0.052)
BIRTHEVENT
-0.018***
(0.005)
educationlevelprimary/middle school
0.079*
(0.033)
educationlevelsecondary/post-primary
0.271***
(0.036)
educationleveltertiary/ post-secondary
0.340***
(0.042)
agegroup20-24
-0.018
(0.022)
agegroup25-29
0.009
(0.026)
agegroup30-34
0.054+
(0.030)
agegroup35-39
0.024
(0.034)
agegroup40-44
-0.013
(0.039)
agegroup45-49
-0.007
(0.042)
maritalcombinedin a union
-0.036*
(0.017)
factor(MCP)1
0.110***
(0.015)
factor(URBAN)1
-0.000
(0.055)
wealthq_stratified_imputedSecond
0.115***
(0.024)
wealthq_stratified_imputedMiddle
0.115***
(0.026)
wealthq_stratified_imputedFourth
0.140***
(0.027)
wealthq_stratified_imputedHighest
0.153***
(0.028)
factor(YEAR)2021
0.039*
(0.015)
factor(YEAR)2022
-0.000
(0.016)
SD (Intercept FQINSTID)
0.254
SD (Intercept EAID)
0.305
SD (Observations)
0.658
N
12150
7. How much between-EA variance is explained urban status or wealth?