Matrix implementation of time variant Goodman-Keyfitz-Pullum equations in a matrix framework.

kin_time_variant(
  p = NULL,
  f = NULL,
  pi = NULL,
  n = NULL,
  output_cohort = NULL,
  output_period = NULL,
  output_kin = NULL,
  birth_female = 1/2.04,
  list_output = FALSE,
  fast = FALSE
)

Arguments

p

numeric. A matrix of survival ratios with rows as ages and columns as years. Column names must be equal interval.

f

numeric. A matrix of age-specific fertility rates with rows as ages and columns as years. Coincident with U.

pi

numeric. A matrix with distribution of childbearing with rows as ages and columns as years. Coincident with U.

n

numeric. A matrix of population with rows as ages and columns as years. Coincident with U.

output_cohort

integer. Year of birth of focal to return as output. Could be a vector. Should be within input data years range.

output_period

integer. Year for which to return kinship structure. Could be a vector. Should be within input data years range.

output_kin

character. kin to return as output: "m" for mother, "d" for daughter,... See vignette for exahustive kin.

birth_female

numeric. Female portion at birth. This can be a vector of length equal to the number of years in the input data, or a single value that will be repeated for all years.

list_output

logical. Results as a list with years elements (as a result of output_cohort and output_period combination), with a second list of output_kin elements, with focal´s age in columns and kin ages in rows (2 * ages, last chunk of ages for death experience). Default FALSE

fast

logical. If FALSE (the default) the model runs with the original R implementation (dense matrix products in R, output tables assembled with dplyr, tidyr and data.table). If TRUE, the same projections run in compiled C++ code and the output tables are built directly, which is typically 5 to 200 times faster on large inputs (long time series, two-sex, cause-of-death or multistate models). The returned object is identical in both cases: same values, same columns, same row order, same classes. Use fast = TRUE for production runs and fast = FALSE to read or step through the model equations in R.

Value

A data frame of population kinship structure, with Focal's cohort, focal´s age, period year, type of relatives (for example d is daughter, oa is older aunts, etc.), living and death kin counts, and age of (living or time deceased) relatives. If list_output = TRUE then this is a list.

Details

See Caswell (2021) for details on formulas.