R/kin_time_variant_2sex.R
kin_time_variant_2sex.RdTwo-sex matrix framework for kin count estimates with varying rates. This produces kin counts grouped by kin, age and sex of each relatives at each Focal´s age. For example, male cousins from aunts and uncles from different sibling's parents are grouped in one male count of cousins.
kin_time_variant_2sex(
pf = NULL,
pm = NULL,
ff = NULL,
fm = NULL,
sex_focal = "f",
birth_female = 1/2.04,
pif = NULL,
pim = NULL,
nf = NULL,
nm = NULL,
output_cohort = NULL,
output_period = NULL,
output_kin = NULL,
list_output = FALSE,
fast = FALSE
)numeric. A vector (atomic) or matrix with probabilities (or survival ratios, or transition between age class in a more general perspective) with rows as ages (and columns as years in case of matrix, being the name of each col the year).
numeric. A vector (atomic) or matrix with probabilities (or survival ratios, or transition between age class in a more general perspective) with rows as ages (and columns as years in case of matrix, being the name of each col the year).
numeric. Same as pf but for fertility rates.
numeric. Same as pm but for fertility rates.
character. "f" for female or "m" for male.
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.
numeric. For using some specific age distribution of childbearing for mothers (same length as ages). Default NULL.
numeric. For using some specific age distribution of childbearing for fathers (same length as ages). Default NULL.
numeric. Same as pf but for population distribution (counts or %). Optional.
numeric. Same as pm but for population distribution (counts or %). Optional.
integer. Vector of year cohorts for returning results. Should be within input data years range.
integer. Vector of period years for returning results. Should be within input data years range.
character. kin types to return: "m" for mother, "d" for daughter,...
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 with year, cohort, Focal´s age, related ages, sex and type of kin (for example d is daughter, oa is older aunts, etc.), including living and dead kin at that age and sex.
See Caswell (2022) for details on formulas.