## Supplement 1. The data and Mathematica codes used in the age-dependent survival analysis of Glanville fritillary butterflies.

## File List

survival_modelI.nb – Mathematica code for model I of survival analysis survival_modelII.nb – Mathematica code for model II of survival analysis individual_analysis.nb – Mathematica code for the analysis of individual errors in death rates MCMCAlgorithms.m – Mathematica package needed to run the above programs MCMCAlgorithms.nb – Used to generate MCMCAlgorithms.m realdata.txt – Data yfor each individual at each censuscovariates.txt – Individual covariates weather.txt – Temperature at each census jlast.txt – The last recapture census of each individual femalemobility.txt – Mobility of females measured by the number of moves between different cells in the closed cage readme.txt – Description of the data files all.zip – A zip of all files

## Description

The files survival_modelI.nb and survival_modelII.nb are Mathematica programs that can be used to estimate the parameters of the main model, and the file individual_analysis.nb performs the regressions relating to individual error terms. All the data files are described in readme.txt.

Download all the files in the same directory. Change in the programs "workdirectory" to the current directory. The data files realdata.txt, covariates.txt, weather.txt, and jlast.txt are needed to run the program survival_xxx.nb. Change the random seed to obtain different starting values. The posterior distributions are saved in the results_xxx.txt files.

In the program individual_analysis.nb, the estimated distribution of individual errors is imported from the file individual_errors.txt. Set “infile” to femalemobility.txt if individual errors are regressed against the individual’s mobility. The posterior distribution is saved to the file "outfile".