Instructions and description for replicability "Divergent trends of lifespan variation during mortality crises" All code was run using RStudio and R version 4.0.2 "Taking Off Again". "0 - Master script.R" is the only script that needs to be opened. It calls all other scripts in the correct order. Please add the path for the "Programmes" folder at the beginning of this script. The "Data" folder contains the "Metadata.txt" file. This file contains information on the data used, especially the Ukrainian data from Meslé and Vallin and from Rudnystki et al. (2015), which are not publicly available. The "Data" folder will be used to store downloaded data from the Human Mortality Database (HMD). If you do not wish to download the HMD data, please skip the "Getting data" section. This section also includes the formatting of the Ukrainian data from Meslé and Vallin. If you do not have these data, please comment this line and all the other lines related to the Ukrainian data (i.e. with "Ukraine" in the name). Getting data ----------------- "Downloading HMD data.R" downloads single-age and abridged period lifetables from the Human Mortality Database (HMD). Requires an Internet connection. Needs manual input to define HMD username and password. "Merging data Ukraine 1933.R" merges separate files containing sex-specific lifetable deaths, life expectancy, survivorship and probability of dying from Meslé and Vallin's database, merges them and uses this information to create complete period lifetables, by sex. Functions ----------------- "Data functions.R" contains basic functions to create lifetables, calculate indicators and threshold ages and to increase or decrease mortality for the sensitivity tests. "Decomposition functions.R" contains functions for the linear integral (Horiuchi) decomposition. "Plotting functions.R" contains functions to create the result graphs. Data wrangling ----------------- "Handling data Iceland 1846.R", "Handling data Iceland 1882.R", "Handling data Sweden 1773.R", "Handling data Sweden 1809.R" and "Handling data Ukraine 1933.R" contain code to clean the data and create the indicators for the corresponding crises. Each creates average lifetables for the pre- and post-crisis periods and calculates indicators for the crisis year, the average pre- and post-crisis periods and for each year separately, by sex. The open age category and the length of the pre- and post-crisis periods can be manually changed in these scripts. Main results ----------------- "Plots Iceland 1846.R", "Plots Iceland 1882.R", "Plots Sweden 1773.R", "Plots Sweden 1809.R" and "Plots Ukraine 1933.R" plot results as shown in the paper. Each plots death rates, absolute and relative lifespan variation trends and decomposition results, by sex. Appendices ----------------- "Other indicators Iceland 1846.R", "Other indicators Iceland 1882.R", "Other indicators Sweden 1773.R", "Other indicators Sweden 1809.R" and "Other indicators Ukraine 1933.R" decompose trends of standard deviation, the coefficient of variation, absolute Gini and relative Gini for the corresponding crisis. "Threshold ages Iceland 1846.R", "Threshold ages Iceland 1882.R", "Threshold ages Sweden 1773.R", "Threshold ages Sweden 1809.R" and "Threshold ages Ukraine 1933.R" estimate threshold ages for lifespan disparity and lifetable entropy. These use single age lifetables, which are created within each script. "Appendix e0" plots and decomposes life expectancy trends for all crises. It also creates the graphs in Appendix A. Sensitivity analyses ---------------------- "Sensitivity mortality levels Iceland 1846.R", "Sensitivity mortality levels Iceland 1882.R", "Sensitivity mortality levels Sweden 1773.R", "Sensitivity mortality levels Sweden 1809.R" and "Sensitivity mortality levels Ukraine 1933.R" increase/decrease mortality at all ages or only for infant ages. Code to increase or decrease mortality at all ages by 10% and to increase mortality at infant ages by 10% is already present, but should be de-commented.