

Code authors: Joe Butterick. 
Paper co-authors: Jason Hilton, Peter W F Smith, Jakub Bijak, Erengul Dodd.


This R project is to be used to replicate the results of the paper "Probabilistic projections of kin over the life-course", published in Demographic Research, 2025. 

The code is developed as an R package, using the "devtools" R library. 

Version R.4.2.2 is used for the theoretical modelling, and Python 3.11 for simulations.

First, type

load(devtools)

and then to load all functions and data used, type

load_all()


You are now ready to produce results!

The folders have the following structure:

R/ contains the theoretical model written in R. 
	- files ending in "_PMF" are the projection functions for kin-types
	- other files are utility functions -- e.g., nth_convolution_function.R defines discrete convolutions of a list of PMFs, and age_mother_func.R infers the maternal age-		  structures

data/ contains data used in the manuscript results, namely, mortality and fertility rates for the UK in 1974, sourced from the ONS.
	- also stored here are the outputs of runs of the simulation model (see below)

Sim/ contains python scripts used to run the agent based model for comparison to the theoretical model (see Appendix figures in text)
	- Boid_Class_PMF creates population members using the class method
	- run implements the population dynamics

means_comparison_Cas2019/ compares the output of this model to the established one of Caswell (2019) "The formal demography of kinship". Of course, here we are simply comparing 	means.

vignettes/ provides some examples of how to use the code to implement the model in text. Here examples of older and younger sisters are given:
	- compute the probable numbers of sisters at fixed age of sister and Focal
	- compute the probable numbers of sisters over all possible ages of sister, and fixed age of Focal
	- compute the probable numbers of sisters over all possible ages of sister, at different ages of Focal

Revision_Figrues/ provides code to replicate all results in the manuscript. As you probably guessed from the folder title, the paper was "revised and resubmitted"!


Best wishes

Joe Butterick (and colleagues)
