Instructions and description for replicability "Differences in mortality before retirement: The role of living arrangements and marital status in Denmark", published in Demographic Research by Serena Vigezzi and Cosmo Strozza. All code was run using RStudio and R version 4.3.1 "Beagle Scout". "0 - Master.R" is the only script that needs to be opened. It calls all other scripts in the correct order. It is located in the main folder, NOT in the script folder. In the main folder, you will also find the R project "Living arrangements and retirement.Rproj". You can either open the "0 - Master.R" script directly, or open the "Living arrangements and retirement.Rproj" project first. The working directory will be the same in both cases. The "Data" folder contains the necessary data. Because of privacy concerns, the raw data are not publicly available. They can be acquired for a fee from Statistics Denmark, by applying with a project description. The "Data" folder contains aggregated data, constructed on the basis of individual register data. Calls to the necessary datasets are already included in the scripts. Bootstrapped data are also provided, as the scripts needed to create them are computationally intensive. The "Plots" folder is empty. It will be used to contain the plots produced by the scripts. "Functions.R" contains tailored functions to find the modal value, calculate the equivalent age and to bootstrap the datsets, creating the necessary measures with confidence intervals. "HH_analysis_50-65.R", "HH_analysis_50-67.R" and "HH_analysis_50-70.R" contain code to calculate the lifetable from the data provided. They also estimate the probability of surviving from age 50 to age 65/67/70 and the equivalent age. "HH_bootstrapping_50-65.R", "HH_bootstrapping_50-67.R" and "HH_bootstrapping_50-70.R" contain code to bootstrap the lifetables created previously. The last two also contain code to estimate the difference in survival whenn changing retirement age. "Figures_main.R" and "Figures_appendix.R" contain code to reproduce the images in the main body of the paper and in the appendices, respectively.