View source: R/calculate_nrr.R
calculate_nrr | R Documentation |
Calculate Net Reproductive Rate (NRR) from age-specific
fertility rate (ASFR), sex-ratio at birth (SRB), and person-years
(nLx) and generate nrr
variable in the data.table.
calculate_nrr(
dt,
id_cols,
reproductive_age_start = 10,
reproductive_age_end = 55
)
dt |
[ |
id_cols |
[ |
reproductive_age_start |
[ |
reproductive_age_end |
[ |
Calculate proportion female: prop_female = (1 / srb) / (1 + (1 / srb)). Then, calculate NRR: sum(asfr * prop_female * nLx) over age, by id columns.
dt [data.table()
]
Data table with nrr
by id_cols
(excluding 'age_start' and 'age_end').
Preston Demography textbook page 113 (Section 5.5 Reproduction Measures).
dt <- data.table::data.table(
age_start = seq(15, 45, 5),
age_end = seq(20, 50, 5),
sex = "female",
asfr = c(0.00002, 0.009, 0.1, 0.18, 0.19, 0.11, 0.03),
srb = 1.057,
nLx = c(4.61, 4.55, 4.48, 4.39, 4.30, 4.18, 4.03)
)
output <- calculate_nrr(
dt,
id_cols = c("age_start", "age_end", "sex"),
reproductive_age_start = 15,
reproductive_age_end = 50
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.