Estimate yearly age-specific fertility rates (ASFR) from a SOCSIM-generated population file
Source:R/estimate_rates.R
estimate_fertility_rates.RdGiven a population file ('opop') generated by rsocsim, the function estimates age-specific fertility rates.
Usage
estimate_fertility_rates(
opop,
final_sim_year,
year_min,
year_max,
year_group = 5,
age_min_fert = 15,
age_max_fert = 50,
age_group = 5
)Arguments
- opop
An R object from SOCSIM microsimulation output (population file).
- final_sim_year
numeric. Final simulated year in 'real world' time ( used to convert 'SOCSIM time' to 'real world' time.)
- year_min
numeric. Lower-bound year for which rate should be estimated.
- year_max
numeric. Upper-bound year for which rate should be estimated.
- year_group
numeric. Size of year groups to estimate rate (year_group=1 will produce single-year estimates)
- age_min_fert
numeric. Lower-bound age of female reproductive period
- age_max_fert
numeric. Upper-bound age of female reproductive period
- age_group
numeric. Size of age groups to estimate rate (age_group=1 will produce single-age estimates)
Value
A data frame with columns year, age, and socsim. year is a
factor describing the grouped calendar-year interval, age is a factor
describing the maternal-age interval, and socsim is the estimated
fertility rate for that cell.
Details
The final_sim_year can be obtained from the .sup file and must
refer to to a real-world year.
Grouped year and age ranges (i.e., if year_group > 1 or age_group > 1)
are created as [year;year+year_group).
Examples
opop <- data.frame(
pid = 1:6,
fem = c(1, 0, 1, 0, 1, 1),
group = 1,
nev = 0,
dob = c(120, 120, 336, 348, 180, 360),
mom = c(0, 0, 1, 1, 0, 5),
pop = c(0, 0, 2, 2, 0, 2),
nesibm = 0,
nesibp = 0,
lborn = 0,
marid = 0,
mstat = 0,
dod = c(0, 300, 0, 0, 0, 0),
fmult = 0
)
asfr <- estimate_fertility_rates(opop = opop,
final_sim_year = 2021,
year_min = 1998,
year_max = 2000,
year_group = 5,
age_min_fert = 15,
age_max_fert = 50,
age_group = 5)
head(asfr)
#> # A tibble: 6 × 3
#> year age socsim
#> <fct> <fct> <dbl>
#> 1 [1997.999,1998.0005) [15,20) NA
#> 2 [1997.999,1998.0005) [20,25) NA
#> 3 [1997.999,1998.0005) [25,30) NA
#> 4 [1997.999,1998.0005) [30,35) NA
#> 5 [1997.999,1998.0005) [35,40) NA
#> 6 [1997.999,1998.0005) [40,45) NA