R/kin_time_variant.R
kin_time_variant.RdMatrix 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
)numeric. A matrix of survival ratios with rows as ages and columns as years. Column names must be equal interval.
numeric. A matrix of age-specific fertility rates with rows as ages and columns as years. Coincident with U.
numeric. A matrix with distribution of childbearing with rows as ages and columns as years. Coincident with U.
numeric. A matrix of population with rows as ages and columns as years. Coincident with U.
integer. Year of birth of focal to return as output. Could be a vector. Should be within input data years range.
integer. Year for which to return kinship structure. Could be a vector. Should be within input data years range.
character. kin to return as output: "m" for mother, "d" for daughter,... See vignette for exahustive kin.
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.
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
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.
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.
See Caswell (2021) for details on formulas.