knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) pkgload::load_all() library(knitr)
::: {.columns} ::: {.column width="30%"}
::: ::: {.column width="70%"}
This is an R package for the demographic analysis of kinship networks using matrix-based models.
It implements methods developed initially by Caswell (2019), and continued in successive papers (like Caswell (2020) or Caswell (2024)) for estimating the number and age distribution of relatives under various demographic assumptions.
::: :::
You can install the development version of DemoKin from GitHub:
# install.packages("remotes") remotes::install_github("IvanWilli/DemoKin") library(DemoKin)
Here's a basic example of how to use DemoKin:
# Run a one-sex time-invariant kinship model using Swedish data from 2015 kin_results <- kin( p = swe_px[,"2015"], # Survival probabilities f = swe_asfr[,"2015"], # Fertility rates time_invariant = TRUE # Use time-invariant model ) # Visualize the expected number of living relatives by age kin_results$kin_summary %>% rename_kin() %>% ggplot2::ggplot(ggplot2::aes(age_focal, count_living)) + ggplot2::geom_line() + ggplot2::facet_wrap(~kin_label, scales = "free_y") + ggplot2::labs( title = "Expected number of living relatives by age", x = "Age of focal individual", y = "Number of relatives" )
For detailed documentation, please visit the DemoKin website.
The site includes several vignettes demonstrating different types of kinship models:
DemoKin
has benefited from the work of many people over the years, including:
Ivan Williams (University of Buenos Aires) leads the technical development of DemoKin
with a particular focus on the implementation of the functions in R.
Diego Alburez-Gutierrez (Max Planck Institute for Demographic Research) coordinates the development of the package.
Hal Caswell (University of Amsterdam) provided crucial MATLAB code for computing matrix kinship models.
Xi Song (University of Pennsylvania) contributed the code to estimate time variant kinship models.
Benjamin Schlüter (University of Toronto) contributed code to implement bereavement analysis by cause of death.
Joe Butterick (University of Southampton) contributed code to implement time-variant, two-sex multistate kinship models.
Jason Hilton (University of Southampton) contributed code to implement time-variant, two-sex multistate kinship models.
Sha Jiang (Max Planck Institute for Demographic Research) helped create and organise the documention for the package, including developing the package’s website.
Amanda Martins (Max Planck Institute for Demographic Research) developed materials for teaching DemoKin, including a course at the European Doctoral School of Demography.
Williams, Iván; Alburez-Gutierrez, Diego; and the DemoKin team. (2021) DemoKin: An R package to implement demographic matrix kinship models. URL: https://github.com/IvanWilli/DemoKin.
We thank Silvia Leek from the Max Planck Institute for Demographic Research for designing the DemoKin logo. The logo includes elements that have been taken or adapted from this file, originally by Ansunando, CC BY-SA 4.0 via Wikimedia Commons. Sha Jiang provided useful comments for improving the package.
DemoKin
is under constant development.
If you're interested in contributing, please get in touch, create an issue, or submit a pull request.
We look forward to hearing from you!
This project is licensed under the MIT License - see the LICENSE file for details.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.