# Exercises for Chapter 5 # Reading data via internet T5E1 <- read.delim("http://minato.sip21c.org/Table5E1.txt") T5E2 <- read.delim("http://minato.sip21c.org/Table5E2.txt") T5E3 <- read.delim("http://minato.sip21c.org/Table5E3.txt") T5E4 <- read.delim("http://minato.sip21c.org/Table5E4.txt") T5E5 <- read.delim("http://minato.sip21c.org/Table5E5.txt") # Complete the table 5E.1 BC0105 <- t(T5E2[1,2:9]) PP0105 <- rev(cumsum(rev(BC0105))) PPR0105 <- PP0105[-1]/PP0105[-8] T5E1[7,2:8] <- as.integer(PPR0105*1000) BC0610 <- t(T5E2[2,2:9]) PP0610 <- rev(cumsum(rev(BC0610))) PPR0610 <- PP0610[-1]/PP0610[-8] T5E1[8,2:8] <- as.integer(PPR0610*1000) print(T5E1) # The pattern of the Table 5E.1: In earlier birth cohort, PPRs are # declining with birth order. In later birth cohort, PPRs are relatively # stable regarding to birth order. # Combine with the predicted value in Table 5E.3 T5E1 <- rbind(T5E1, T5E3) # Compare the PPRs among 3 birth cohorts: 1871-5, 1896-1900, and 1931-5 by graphical means T5E1X <- T5E1[c(1, 6, 9),] # same as subset(T5E1, BC %in% c("1871-1875", "1896-1900", "1931-1935")) matplot(t(T5E1X[, 2:8]), type="b", pch=1:3, col=1, lty=1:3, xlab="Parity", ylab="PPRs") legend("topright", pch=1:3, col=1, lty=1:3, legend=T5E1X$BC) # Why might the patterns be occurring? # There may be 2 reasons: (1) Prediction error and (2) Bipolarization of cohort fertility # ** Exercise 2 ** # Estimate the mean family size achieved by the non-manual group of women (calculate for each group) PPR4 <- T5E4[, 2:6] products4 <- PPR4 for (i in 2:5) products4[, i] <- products4[, i-1]*PPR4[, i] # "for" makes a loop with specified times. rowSums(products4) # Cohort fertility rate (thus mean family size) for each group # Calculate PPRs for two groups of women who married 1951-60 NWNM <- T5E5[,2] NWM <- T5E5[,3] XNWNM <- rev(cumsum(rev(NWNM))) XNWM <- rev(cumsum(rev(NWM))) PPR5 <- rbind(XNWNM[-1]/XNWNM[-6],XNWM[-1]/XNWM[-6]) # PPRs for each group, shown in similar format as Table 5E.4 print(PPR5) # As general trends, PPRs are decreasing. # Both PPR3-4 and PPR4-5 showed large declines for Manual workers, # but only PPR3-4 showed large decline for Non-manual workers. # # Differentials and trends in cohort fertility products5 <- PPR5 for (i in 2:5) products5[, i] <- products5[, i-1]*PPR5[, i] rowSums(products5) # Cohort fertility rates for each group # CFRs largely decreased for manual workers, but slightly increased for non-manual workers. # Limitation and misleading # 1951-60 married cohort has not completed their reproduction.