Function to smooth mortality rates using MortalityLaw package
Source:R/smooth_mortality_law.R
smooth_mortality_law.Rd
This smoothing function allows smoothing of a variable in a vital object using
the MortalityLaw package.
The vital object is returned along with some additional columns containing
information about the smoothed variable: .smooth
containing the
smoothed values, and .smooth_se
containing the corresponding standard errors.
Arguments
- .data
A vital object
- .var
name of variable to smooth. This should contain mortality rates.
- law
name of mortality law. For available mortality laws, users can check the
availableLaws
. Argument ignored if a custom law supplied. function to learn about the available options.- ...
Additional arguments are passed to
MortalityLaw
.
Examples
norway_mortality |> smooth_mortality_law(Mortality)
#> # A vital: 40,959 x 8 [1Y]
#> # Key: Age x Sex [111 x 3]
#> Year Age OpenInterval Sex Population Mortality .smooth .smooth_se
#> <int> <int> <lgl> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 1900 0 FALSE Female 30070 0.0778 0.00197 0.000146
#> 2 1900 1 FALSE Female 28960 0.0290 0.00207 0.000154
#> 3 1900 2 FALSE Female 28043 0.0123 0.00218 0.000161
#> 4 1900 3 FALSE Female 27019 0.00786 0.00229 0.000170
#> 5 1900 4 FALSE Female 26854 0.00624 0.00241 0.000179
#> 6 1900 5 FALSE Female 25569 0.00538 0.00253 0.000188
#> 7 1900 6 FALSE Female 25534 0.00422 0.00266 0.000197
#> 8 1900 7 FALSE Female 24314 0.00376 0.00280 0.000208
#> 9 1900 8 FALSE Female 24979 0.00380 0.00295 0.000218
#> 10 1900 9 FALSE Female 24428 0.00365 0.00310 0.000230
#> # ℹ 40,949 more rows