R routines associated to the publication
"Smooth Constrained Mortality Forecasting" by Carlo G. Camarda
Demographic Research.
Volume 41, Article 38, pages 1091-1130.
Published 24 October 2019.
http://www.demographic-research.org/Volumes/Vol41/38/
DOI: 10.4054/DemRes.2019.41.38
Prepared on 2019.09.03
R files were created using version 3.6.1
Requirements in terms of R codes and packages are described in the preamble of each file
Specifically, registration to the Human Mortality Database is required for running all presented examples. Using the R-package "HMDHFDplus", the code will prompt for the HMD user name and password
Alternatively and for illustrative purposes, see code in 2. for estimating the main model on a sample dataset
Codes are extensively commented and object-names follow as much as possible notation as presented in the publication.
The .zip archive contains the files listed below:
1. R-code for estimating CP-splines as presented in the publication
SmoothConstrainedMortalityForecasting_MainProgram.R
2. R-code for estimating CP-splines as presented in the publication for a single sample dataset (USA, males, ages 0-105, years 1960-2016, forecast up to 2050)
SmoothConstrainedMortalityForecasting_MainProgramUSAmales.R
3. Sample dataset containing death counts for USA males ages 0-105, years 1960-2016. See MetaInformationSampleData.txt for details.
DeathsUSAm.txt
4. Sample dataset containing exposure population for USA males ages 0-105, years 1960-2016. See MetaInformationSampleData.txt for details.
ExposuresUSAm.txt
5. Information about data in DeathsUSAm.txt and ExposuresUSAm.txt
MetaInformationSampleData.txt
6. R-code with a set of functions useful for modelling and forecasting based on CP-splines
SmoothConstrainedMortalityForecasting_Functions.R
7. R-code with a set of functions useful for building life-table based on different inputs and extract e-dagger from it
SmoothConstrainedMortalityForecasting_LifeTableFunctions.R
8. R-code for estimating a smooth version of the Lee-Carter model as in Delwarde et al. (2007). Smoothing the Lee-Carter and Poisson log-bilinear models for mortality forecasting: A penalized log-likelihood approach. Statistical Modelling 7, 29–48.
SmoothConstrainedMortalityForecasting_SmoothLeeCarterFunctions.R
9. R-code for running the out-of-sample forecast exercise for comparing CP-splines with alternative forecasting approaches as presented in the publication (and Supplementary Material)
SmoothConstrainedMortalityForecasting_OutOfSample.R
10. R-code for assessing the effect of the change in confidence level in rate-of-change over time for CP-splines as presented in the Supplementary Material of the publication
SmoothConstrainedMortalityForecasting_ChangingTimeConstraints.R
11. R-code for assessing the effect of the change in time-windows for CP-splines and Hyndman-Ullah model as presented in the Supplementary Material of the publication
SmoothConstrainedMortalityForecasting_TimeWindow.R