Estimate yearly age-specific mortality rates (ASMR) from a SOCSIM-generated population file
Source:R/estimate_rates.R
estimate_mortality_rates.RdGiven a population file ('opop') generated by rsocsim, the function estimates (yearly) age-specific mortality rates.
Usage
estimate_mortality_rates(
opop,
final_sim_year,
year_min,
year_max,
year_group,
age_max_mort,
age_group
)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_max_mort
numeric. Maximum age for estimating mortality.
- 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, sex, age, and socsim.
year is a factor describing the grouped calendar-year interval,
sex is "male" or "female", age is a factor describing the age
interval, and socsim is the estimated mortality 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). For age_group > 1, mortality rates
are split into an infant group [0,1) and then grouped ages [1, age_group),
[age_group, age_group + age_group), and so on.
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
)
asmr <- estimate_mortality_rates(opop = opop,
final_sim_year = 2021,
year_min = 1995,
year_max = 2000,
year_group = 5,
age_max_mort = 100,
age_group = 5)
head(asmr)
#> # A tibble: 6 × 4
#> year sex age socsim
#> <fct> <chr> <fct> <dbl>
#> 1 [1995,2000) male [0,1) NA
#> 2 [1995,2000) male [1,5) NA
#> 3 [1995,2000) male [5,10) NA
#> 4 [1995,2000) male [10,15) NA
#> 5 [1995,2000) male [15,20) NA
#> 6 [1995,2000) male [20,25) NA