Computer files for Caswell, H. 2014. A matrix approach to the statistics of longevity in the gamma-Gompertz and related heterogeneous frailty models. Demographic Research. This folder contains two Matlab files: gamma_gompertz_mortality.m This is a Matlab script that computes the statistics of longevity for the example of Swedish females, 1950, based on parameters for the gamma-Gompertz model reported in Table 1 of Missov (2013). This sp_vecperm.m This is a Matlab function that generates a sparse vec-permutation matrix. This function is called by gamma_gompertz_mortality.m. Using sparse matrix methods is useful because some of the matrices involved in the analysis are very large, but composed mostly of zeros.