The formal demography of kinship: A matrix formulation
Demographic Research
Hal Caswell
Description of code provided as Supplementary Materials
This supplement contains 6 files that permit carrying out the calculations for the kinship dynamics described in the paper. The code is written in Matlab (Mathworks, Natick, MA 01760-2098, USA). It has been run under version R2017a, although it should be widely compatible because it does not use any fancy commands.
All files are in plain ASCII format and can be opened with any text editor.
kinship_function_DR.m is a Matlab function file. It takes as input arguments the matrix U containing survival probabilities on the subdiagonal, and the matrix F containing fertility (female offspring per female) in the first row. It returns as outputs a Matlab structure array with two fields:
allkin: This is a 3-dimensional array. Rows=ages of kin, Columns = ages of Focal, Pages = type of kin, from 1 to 14. The types of kin are identified in comments within the program file.
allkin2: This is the same output, but aggregated to 10 kin types by combining younger and older sisters, etc.
The calculations embedded within kinship_function_DR can be extracted and implemented as stand-alone commands, as desired.
kin_program.m: This is a script file that reads in qx and fx schedules from the provided .csv filea and then calls the function program. It includes demonstration of how to compute, from the function output, some of the kin outputs reported in the paper.
qx_years.csv and fx_years.csv: These are ASCII files containing as columns the mortality (q(x)) and fertility (f(x)) schedules for Japanese females from 1947 to 2014. Values were obtained from the Human Mortality Database and the Human Fertility Database.
dementia2015.csv: This is an ASCII file containing the age-specific prevalence of dementia among Japanese women in 2015, as used in the manuscript.