undo_sd {vital}R Documentation

Undo a mean/difference transformation

Description

Make a new vital from means and differences of a measured variable by a key variable. The most common use case of this function is for computing migration numbers by sex, from the sex differences and mean of the numbers.

Usage

undo_sd(.data, .var, key = Sex, times = 2000)

Arguments

.data

A vital object

.var

A bare variable name of the measured variable to use.

key

A bare variable name specifying the key variable to use. This key variable must include the value geometric_mean.

times

When the variable is a distribution, the product must be computed by simulation. This argument specifies the number of simulations to use.

Value

A vital object

References

Hyndman, R.J., Booth, H., & Yasmeen, F. (2013). Coherent mortality forecasting: the product-ratio method with functional time series models. Demography, 50(1), 261-283.

Examples

# Make sums and differences
mig <- net_migration(norway_mortality, norway_births) |>
  dplyr::filter(Sex != "Total")
sd <- mig |>
  make_sd(NetMigration)
# Undo products and ratios
sd |> undo_sd(NetMigration)

[Package vital version 1.1.0 Index]