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.
#start date is 2020?#end date is 2022#fertility preferences and marital status are time-varying covariates and per person there should be 3 observationslibrary(janitor)
Attaching package: 'janitor'
The following objects are masked from 'package:stats':
chisq.test, fisher.test
#recoding#fertility preferences: time-varyingpmauglongfilter<-pmauglong%>%mutate(FERTPREF=as.factor(FERTPREF))%>%mutate(wantanotherchild=recode(FERTPREF, '1'="have another child" ,'2'="no more children", '3'="infertile", .default =NA_character_))tabyl(pmauglongfilter, wantanotherchild)
wantanotherchild n percent valid_percent
have another child 10043 0.70835097 0.7378049
no more children 3360 0.23698688 0.2468410
infertile 209 0.01474115 0.0153541
<NA> 566 0.03992100 NA
pregnant n percent valid_percent
not pregnant 12709 0.89638877 0.90785056
pregnant 1290 0.09098603 0.09214944
<NA> 179 0.01262519 NA
#marital status time-varyingpmauglongfilter<-pmauglongfilter%>%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(pmauglongfilter, 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-grouppmauglongfilter<-pmauglongfilter %>%mutate(agegroup =case_when( AGE >=15& AGE <=19~"15-19", AGE >=20& AGE <=25~"20-25", AGE >=26& AGE <=30~"26-30", AGE >=31& AGE <=35~"31-35", AGE >=36& AGE <=40~"36-40", AGE >=41& AGE <=44~"41-44", AGE >=45& AGE <=49~"45-49" ))#contraceptive use: time-varyingpmauglongfilter<-pmauglongfilter%>%mutate(MCP=as.factor(MCP))%>%mutate(usingmoderncon=recode(MCP, '1'="yes" ,'0'="no",.default =NA_character_))tabyl(pmauglongfilter, usingmoderncon)
usingmoderncon n percent valid_percent
no 9307 0.65643955 0.666261
yes 4662 0.32881930 0.333739
<NA> 209 0.01474115 NA
hazardanalysis<-cleaned_joined_dropcensored%>%filter(wantanotherchild!="NA")hazardanalysis%>%group_by(YEAR, wantanotherchild)%>%summarise(prop_bir=mean(birtheventvar, na.rm=T))%>%ggplot(aes(x=YEAR, y=prop_bir))+geom_line(aes(group=factor(wantanotherchild), color=factor(wantanotherchild)))+ggtitle(label ="Hazard of having a birth after baseline by fertility preference")
`summarise()` has grouped output by 'YEAR'. You can override using the
`.groups` argument.
hazardanalysis2<-cleaned_joined_dropcensored%>%filter(maritalstatus!="NA")hazardanalysis2%>%group_by(YEAR, maritalstatus)%>%summarise(prop_bir=mean(birtheventvar, na.rm=T))%>%ggplot(aes(x=YEAR, y=prop_bir))+geom_line(aes(group=factor(maritalstatus), color=factor(maritalstatus)))+ggtitle(label ="Hazard of having a birth after baseline by marital status")
`summarise()` has grouped output by 'YEAR'. You can override using the
`.groups` argument.
#general model with sociodemographics and fertiltiy preferencesfit.1<-glm(birtheventvar~as.factor(YEAR)+ usingmoderncon+ maritalstatus+ wantanotherchild +AGE, data=hazardanalysis, family=binomial(link="cloglog"))summary(fit.1)
Call:
glm(formula = birtheventvar ~ as.factor(YEAR) + usingmoderncon +
maritalstatus + wantanotherchild + AGE, family = binomial(link = "cloglog"),
data = hazardanalysis)
Coefficients:
Estimate Std. Error z value
(Intercept) -2.001319 0.134910 -14.835
as.factor(YEAR)2021 0.459384 0.061864 7.426
as.factor(YEAR)2022 -0.086481 0.072110 -1.199
usingmodernconyes -0.391094 0.053577 -7.300
maritalstatuscurrently married 1.617935 0.120108 13.471
maritalstatuscurrently living with partner 1.513600 0.114761 13.189
maritalstatusformerly in union 1.143245 0.135730 8.423
maritalstatuswidow or widower 1.131481 0.217932 5.192
wantanotherchildno more children 0.023659 0.068484 0.345
wantanotherchildinfertile -0.178285 0.220659 -0.808
AGE -0.025464 0.004038 -6.307
Pr(>|z|)
(Intercept) < 2e-16 ***
as.factor(YEAR)2021 1.12e-13 ***
as.factor(YEAR)2022 0.230
usingmodernconyes 2.88e-13 ***
maritalstatuscurrently married < 2e-16 ***
maritalstatuscurrently living with partner < 2e-16 ***
maritalstatusformerly in union < 2e-16 ***
maritalstatuswidow or widower 2.08e-07 ***
wantanotherchildno more children 0.730
wantanotherchildinfertile 0.419
AGE 2.85e-10 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 7932.4 on 7389 degrees of freedom
Residual deviance: 7488.3 on 7379 degrees of freedom
(122 observations deleted due to missingness)
AIC: 7510.3
Number of Fisher Scoring iterations: 5
hazardanalysis3<-cleaned_joined_dropcensored%>%filter(decidefp!="NA")hazardanalysis3%>%group_by(YEAR, decidefp)%>%summarise(prop_bir=mean(birtheventvar, na.rm=T))%>%ggplot(aes(x=YEAR, y=prop_bir))+geom_line(aes(group=factor(decidefp), color=factor(decidefp)))+ggtitle(label ="Hazard of having a birth after baseline by family planning user decision-maker")
`summarise()` has grouped output by 'YEAR'. You can override using the
`.groups` argument.
hazardanalysis4<-cleaned_joined_dropcensored%>%filter(decidemedical!="NA")hazardanalysis4%>%group_by(YEAR, decidemedical)%>%summarise(prop_bir=mean(birtheventvar, na.rm=T))%>%ggplot(aes(x=YEAR, y=prop_bir))+geom_line(aes(group=factor(decidemedical), color=factor(decidemedical)))+ggtitle(label ="Hazard of having a birth after baseline by medical decision-maker")
`summarise()` has grouped output by 'YEAR'. You can override using the
`.groups` argument.
# general model plus male influence variable on family planning usefit.2<-glm(birtheventvar~as.factor(YEAR)+ usingmoderncon+ maritalstatus+AGE+ wantanotherchild+ decidefp, data=hazardanalysis, family=binomial(link="cloglog"))summary(fit.2)
Call:
glm(formula = birtheventvar ~ as.factor(YEAR) + usingmoderncon +
maritalstatus + AGE + wantanotherchild + decidefp, family = binomial(link = "cloglog"),
data = hazardanalysis)
Coefficients:
Estimate Std. Error z value
(Intercept) -1.102660 0.274468 -4.017
as.factor(YEAR)2021 0.342608 0.098485 3.479
as.factor(YEAR)2022 -0.039740 0.114975 -0.346
usingmodernconyes -0.401104 0.098567 -4.069
maritalstatuscurrently married 0.707437 0.214470 3.299
maritalstatuscurrently living with partner 0.705469 0.206247 3.421
maritalstatusformerly in union 0.379899 0.254408 1.493
maritalstatuswidow or widower 0.510620 0.435380 1.173
AGE -0.020928 0.007127 -2.936
wantanotherchildno more children -0.021351 0.113552 -0.188
wantanotherchildinfertile -0.246512 0.460172 -0.536
decidefphusband/partner -0.297557 0.140697 -2.115
decidefpjoint decision -0.225164 0.086743 -2.596
Pr(>|z|)
(Intercept) 5.88e-05 ***
as.factor(YEAR)2021 0.000504 ***
as.factor(YEAR)2022 0.729612
usingmodernconyes 4.71e-05 ***
maritalstatuscurrently married 0.000972 ***
maritalstatuscurrently living with partner 0.000625 ***
maritalstatusformerly in union 0.135367
maritalstatuswidow or widower 0.240870
AGE 0.003321 **
wantanotherchildno more children 0.850854
wantanotherchildinfertile 0.592169
decidefphusband/partner 0.034440 *
decidefpjoint decision 0.009438 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 3075.2 on 2981 degrees of freedom
Residual deviance: 3009.3 on 2969 degrees of freedom
(4530 observations deleted due to missingness)
AIC: 3035.3
Number of Fisher Scoring iterations: 5
#general model plus male influence variables on medical decision makingfit.3<-glm(birtheventvar~as.factor(YEAR)+ usingmoderncon+ maritalstatus+AGE + wantanotherchild+ decidemedical, data=hazardanalysis, family=binomial(link="cloglog"))summary(fit.3)
Call:
glm(formula = birtheventvar ~ as.factor(YEAR) + usingmoderncon +
maritalstatus + AGE + wantanotherchild + decidemedical, family = binomial(link = "cloglog"),
data = hazardanalysis)
Coefficients:
Estimate Std. Error z value
(Intercept) -0.416483 0.164056 -2.539
as.factor(YEAR)2021 0.480375 0.070164 6.846
as.factor(YEAR)2022 0.003790 0.080403 0.047
usingmodernconyes -0.437043 0.058312 -7.495
maritalstatuscurrently living with partner -0.105899 0.056668 -1.869
AGE -0.026485 0.004574 -5.791
wantanotherchildno more children 0.052727 0.075441 0.699
wantanotherchildinfertile -0.361347 0.277952 -1.300
decidemedicalhusband/partner 0.102957 0.069663 1.478
decidemedicalsomeone else -0.041043 0.079222 -0.518
Pr(>|z|)
(Intercept) 0.0111 *
as.factor(YEAR)2021 7.57e-12 ***
as.factor(YEAR)2022 0.9624
usingmodernconyes 6.64e-14 ***
maritalstatuscurrently living with partner 0.0617 .
AGE 7.00e-09 ***
wantanotherchildno more children 0.4846
wantanotherchildinfertile 0.1936
decidemedicalhusband/partner 0.1394
decidemedicalsomeone else 0.6044
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 6017.0 on 5185 degrees of freedom
Residual deviance: 5797.7 on 5176 degrees of freedom
(2326 observations deleted due to missingness)
AIC: 5817.7
Number of Fisher Scoring iterations: 5