Implementation of two-sex matrix kinship model. 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. Note that the output labels relative following female notation: the label m
refers to either mothers or fathers, and column sex_kin
determine the sex of the relative.
kin2sex(
pf = NULL,
pm = NULL,
ff = NULL,
fm = NULL,
time_invariant = TRUE,
sex_focal = "f",
birth_female = 1/2.04,
pif = NULL,
pim = NULL,
nf = NULL,
nm = NULL,
Hf = NULL,
Hm = NULL,
output_cohort = NULL,
output_period = NULL,
output_kin = NULL,
output_age_focal = NULL,
summary_kin = TRUE
)
numeric. A vector (atomic) or matrix with female 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 male 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.
logical. Constant assumption for a given year
rates. Default TRUE
.
character. "f" for female or "m" for male.
numeric. Female portion at birth. This multiplies f
argument. If f
is already for female offspring, this needs to be set as 1.
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. Only for time_invariant = FALSE
. Same as pf
but for population distribution (counts or %
). Optional.
numeric. Only for time_invariant = FALSE
. Same as pm
but for population distribution (counts or %
). Optional.
numeric. A list where each list element (being the name of each list element the year) contains a matrix with cause-specific hazards for females with rows as causes and columns as ages, being the name of each col the age.
numeric. A list where each list element (being the name of each list element the year) contains a matrix with cause-specific hazards for males with rows as causes and columns as ages, being the name of each col the age.
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,...
integer. Vector of ages to select (and make faster the run).
logical. Whether or not include kin_summary
table (see output details). Default TRUE
.
A list with:
kin_full a data frame with year, cohort, Focal´s age, related ages and type of kin (for example d
could be daughter or son depending sex_kin
,
oa
is older aunts or uncles also depending sex_kin
value, etc.), including living and dead kin at that age.
kin_summary a data frame with Focal´s age, related ages, sex and type of kin, with indicators obtained processing kin_full
, grouping by cohort or period (depending on the given arguments):
count_living
: count of living kin at actual age of Focal
mean_age
: mean age of each type of living kin.
sd_age
: standard deviation of age of each type of living kin.
count_death
: count of dead kin at specific age of Focal.
count_cum_death
: cumulated count of dead kin until specific age of Focal.
mean_age_lost
: mean age where Focal lost her relative.
See Caswell (2022) for details on formulas.
# Kin expected count by relative sex for a French female based on 2012 rates.
fra_fert_f <- fra_asfr_sex[,"ff"]
fra_fert_m <- fra_asfr_sex[,"fm"]
fra_surv_f <- fra_surv_sex[,"pf"]
fra_surv_m <- fra_surv_sex[,"pm"]
fra_2012 <- kin2sex(fra_surv_f, fra_surv_m, fra_fert_f, fra_fert_m)
head(fra_2012$kin_summary)
#> # A tibble: 6 × 11
#> age_focal kin sex_kin year cohort count_living mean_age sd_age count_dead
#> <int> <chr> <chr> <lgl> <lgl> <dbl> <dbl> <dbl> <dbl>
#> 1 0 coa f NA NA 1.27 9.55 7.18 0.000236
#> 2 0 coa m NA NA 1.32 9.54 7.17 0.000408
#> 3 0 cya f NA NA 0.455 5.19 4.84 0.000109
#> 4 0 cya m NA NA 0.473 5.19 4.84 0.000143
#> 5 0 d f NA NA 0 NaN NaN 0
#> 6 0 d m NA NA 0 NaN NaN 0
#> # ℹ 2 more variables: count_cum_dead <dbl>, mean_age_lost <dbl>