Two-sex matrix framework for kin count and death estimates.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. This also produces kin deaths grouped by kin, age, sex of each relatives at each Focal´s age, and cause of death.

kin_time_invariant_2sex_cod(
  pf = NULL,
  pm = NULL,
  ff = NULL,
  fm = NULL,
  Hf = NULL,
  Hm = NULL,
  sex_focal = "f",
  birth_female = 1/2.04,
  pif = NULL,
  pim = NULL,
  output_kin = NULL,
  list_output = FALSE,
  fast = FALSE
)

Arguments

pf

numeric. A vector of survival probabilities for females with same length as ages.

pm

numeric. A vector of survival probabilities for males with same length as ages.

ff

numeric. A vector of age-specific fertility rates for females with same length as ages.

fm

numeric. A vector of age-specific fertility rates for males with same length as ages.

Hf

numeric. A matrix with cause-specific hazards for females with rows as causes and columns as ages, being the name of each col the age.

Hm

numeric. A matrix with cause-specific hazards for males with rows as causes and columns as ages, being the name of each col the age.

sex_focal

character. "f" for female or "m" for male.

birth_female

numeric. Female portion at birth.

pif

numeric. For using some specific non-stable age distribution of childbearing for mothers (same length as ages). Default NULL.

pim

numeric. For using some specific non-stable age distribution of childbearing for fathers (same length as ages). Default NULL.

output_kin

character. kin to return, considering matrilineal names. For example "m" for parents, "d" for children, etc. See the vignette for all kin types.

list_output

logical. Results as a list with 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 with focal´s age, related ages and type of kin (for example d is children, oa is older aunts/uncles, etc.), sex, alive and death. If list_output = TRUE then this is a list.

Details

See Caswell (2022) for details on formulas.