Title: | Parametric and Non-Parametric Demographic Functions and Applications |
---|---|
Description: | Calculate parametric mortality and Fertility models, following packages 'BaSTA' in Colchero, Jones and Rebke (2012) <doi:10.1111/j.2041-210X.2012.00186.x> and 'BaFTA' <https://github.com/fercol/BaFTA>, summary statistics (e.g. ageing rates, life expectancy, lifespan equality, etc.), life table and product limit estimators from census data. |
Authors: | Fernando Colchero [aut, cre] |
Maintainer: | Fernando Colchero <[email protected]> |
License: | GPL |
Version: | 1.0.2 |
Built: | 2025-02-15 06:10:14 UTC |
Source: | https://github.com/fercol/paramdemo |
Functions for parametric and non-parametric calculations of survival, mortality and fertility
Package: | paramDemo |
Type: | Package |
Version: | 1.0.2 |
Date: | 2025-01-16 |
License: | GNU General Public Licence |
LazyLoad: | yes |
This package contains functions for calculations of parametric mortality, survival and fertility models, as well as non-parametric methods for life tables and product limit estimators.
Fernando Colchero [email protected]
CalcAgeingRateMort
and CalcAgeingRateFert
are used to calculate actuarial and reproductive ageing rates from parametric models of mortality and fertility.
CalcAgeingRateMort(theta, x, model = "GO", shape = "simple", checkTheta = TRUE) CalcAgeingRateFert(beta, x, modelFert = "quadratic", ageMatur = 0, checkBeta = TRUE)
CalcAgeingRateMort(theta, x, model = "GO", shape = "simple", checkTheta = TRUE) CalcAgeingRateFert(beta, x, modelFert = "quadratic", ageMatur = 0, checkBeta = TRUE)
theta |
Numerical vector of age-specific mortality parameters (see details). |
beta |
Numerical vector of age-specific fertility parameters (see details.) |
x |
Numerical vector of ages at which to calculate mortality. |
model |
The underlying mortality model to be used. |
shape |
The overall shape of the model. Values are: |
modelFert |
Age-specific fertility model. Options are “ |
ageMatur |
Numerical value for the age at sexual maturity. |
checkTheta |
Logical to verify that the |
checkBeta |
Logical to verify that the |
The function CalcAgeingRateMort
uses parametric functions to calculate the actuarial (i.e., mortality) rate of ageing. The function follows the conventions from package BaSTA (Colchero and Clark 2012, Colchero et al. 2012, Colchero et al. 2021) to select the parametric model of mortality. The mortality function describes how the risk of mortality changes with age, and is defined as
where is a random variable for ages at death,
are ages and
is the vector of mortality parameters. (For further details on the mortality and survival models see
CalcMort
).
Given a vector of ages specified by the user with argument
x
, the function calculates ageing rates at age as
for .
Similarly, function CalcAgeingRatesFert
calculate reproductive ageing rates from parametric models of age-specific fertility, . It uses a numerical approximation to
for .
The functions output a matrix with the ages at which ageing rates were calculated, the estimated actuarial rate of ageing, and the level of survival at that age.
Fernando Colchero [email protected]
CalcSurv
to calculate age-specific survival, CalcMort
to calculate age-specific mortality, CalcFert
to calculate age-specific fertility.
CalcAgeMaxFert
to calculate the age at maximum fertility from parametric models of age-specific fertility. CalcRemainLifeExp
to calculate remaining life expectancy from parametric models of age-specific mortality.
# Calculate actuarial ageing rate from Gompertz model: arm <- CalcAgeingRateMort(theta = c(b0 = -5, b1 = 0.1), x = 10) # Calculate reproductive ageing rate from quadratic model: arf <- CalcAgeingRateFert(beta = c(b0 = 2, b1 = 0.0025, b2 = 2), x = 10, modelFert = "quadratic")
# Calculate actuarial ageing rate from Gompertz model: arm <- CalcAgeingRateMort(theta = c(b0 = -5, b1 = 0.1), x = 10) # Calculate reproductive ageing rate from quadratic model: arf <- CalcAgeingRateFert(beta = c(b0 = 2, b1 = 0.0025, b2 = 2), x = 10, modelFert = "quadratic")
CalcAgeMaxFert
is used to calculate the age at maximum fertility, and the maximum fertility level from parametric models of fertility.
CalcAgeMaxFert (beta, modelFert = "quadratic", ageMatur = 0, maxAge = 100)
CalcAgeMaxFert (beta, modelFert = "quadratic", ageMatur = 0, maxAge = 100)
beta |
Numerical vector of age-specific fertility parameters (see details). |
modelFert |
Age-specific fertility model. Options are “ |
ageMatur |
Numerical value for the age at sexual maturity. |
maxAge |
Numerical value for the maximum possible age of reproduction. |
For a given function of age-specific fertility,
CalcAgeMaxFert
uses either an analytical solution to
or a numerical approximation. For details of the parametric models available see CalcFert
.
The function outputs a vector with the calculated or estimated age at maximum fertility, the maximum level of fertility, the error in the estimation and the number of iterations (for numerical approximations), and the age at maturity as specified by the user.
Fernando Colchero [email protected]
CalcSurv
to calculate age-specific survival, CalcMort
to calculate age-specific mortality, CalcFert
to calculate age-specific fertility.
CalcAgeingRateMort
to calculate ageing rates from parametric models of age-specific mortality. CalcRemainLifeExp
to calculate remaining life expectancy from parametric models of age-specific mortality.
# Calculate age at maximum fertility from quadratic model: maxg <- CalcAgeMaxFert(beta = c(b0 = 0.5, b1 = 0.01, b2 = 10)) # Calculate age at maximum fertility from gamma model: maxg <- CalcAgeMaxFert(beta = c(b0 = 13, b1 = 2, b2 = 0.15), modelFert = "gamma")
# Calculate age at maximum fertility from quadratic model: maxg <- CalcAgeMaxFert(beta = c(b0 = 0.5, b1 = 0.01, b2 = 10)) # Calculate age at maximum fertility from gamma model: maxg <- CalcAgeMaxFert(beta = c(b0 = 13, b1 = 2, b2 = 0.15), modelFert = "gamma")
CalcDemo
is used to calculate age-specific demographic rates and summary statistics from parametric models of survival and fertility.
CalcDemo(theta = NULL, beta = NULL, x = NULL, dx = NULL, model = "GO", shape = "simple", modelFert = "quadratic", type = "both", minSx = 0.01, summarStats = TRUE, ageMatur = 0, maxAge = NULL, agesAR = NULL, SxValsAR = NULL)
CalcDemo(theta = NULL, beta = NULL, x = NULL, dx = NULL, model = "GO", shape = "simple", modelFert = "quadratic", type = "both", minSx = 0.01, summarStats = TRUE, ageMatur = 0, maxAge = NULL, agesAR = NULL, SxValsAR = NULL)
theta |
Numerical vector of age-specific mortality parameters (see details). |
beta |
Numerical vector of age-specific fertility parameters (see details). |
x |
Numerical vector of ages. If |
dx |
Numerical value for age increments. If |
model |
Mortality model, options are “ |
shape |
The overall shape of the mortality model. Values are: “ |
modelFert |
Age-specific fertility model. Options are “ |
type |
Character string specifying the demographic rates to be calculated. Options are “ |
minSx |
Numerical value specifying the lower bound of the survival function to find the maximum age. The default is 0.01. |
summarStats |
Logical specifying whether summary statistics such as life expectancy, lifespan equality and ageing rates at the specified ages should be calculated. |
ageMatur |
Numerical value specifying the age at sexual maturity, used as the lower bound for the age-specific fertility. Default is 0. |
maxAge |
Numerical values for the maximum age for survival and fertility demographic rates. If |
agesAR |
Numerical vector of ages at which ageing rates should be calculated. If |
SxValsAR |
Alternative to |
1) Age-specific mortality and survival models:
The function CalcDemo
uses parametric functions to calculate age-specific survival, defined as the probability of surviving to a given age. The function follows the conventions from package BaSTA (Colchero and Clark 2012, Colchero et al. 2012, Colchero et al. 2021). The mortality function describes how the risk of mortality changes with age, and is defined as
where is a random variable for ages at death,
are ages and
is the vector of mortality parameters. From the mortality function, the survival function is then given by
1.1)
Argument
“model
”:
The model
argument allows the user to choose between four basic mortality functions, namely
(a) model =
“EX
”: The exponential model (Cox and Oakes 1974), with constant mortality with age, specified as
where , with survival
(b) model =
“GO
”: The Gompertz mortality model (Gompertz 1925, Pletcher 1999), calculated as
where , with survival
(c) model =
“WE
”: The Weibull mortality model (Pinder III et al. 1978) calculated as
where , with survival
(d) model =
“LO
”: The logistic mortality model (Pletcher 1999), calculated as
where , with survival
1.2)
Argument
“shape
”:
The shape
argument allows the user to extend these models in order to explore more complex mortality shapes.
(a) shape =
“simple
”: (default) Leaves the model as defined above, with mortality given by
and survival
(b) shape =
“Makeham
”: A constant is added to the mortality, such that the mortality is given by
where , and with survival
The most common models with this shape is the Gompertz-Makeham model (Gompertz 1825, Makeham 1866).
(c) shape =
“bathtub
”: produces a concave shapes in mortality by adding a declining Gompertz term and a constant parameter to the basic mortality model, where the mortality function is
where ,
and
are specified based on argument
model
, and with survival
The most widely use “bathtub
” shaped model is the Siler mortality model (Siler 1979), which provides considerably good fits to mammalian data. The arguments for the Siler model are:
CalcDemo(..., model = "GO", shape = "bathtub", ...)
2) Specifying theta parameters:
Argument theta
requires a numerical vector of parameters. For instance, for a Gompertz model with simple shape and with parameter vector where
and
, the argument should be specified as
CalcDemo(theta = c(b0 = -5, b1 = 0.1), ...)
Note that in this example the parameter names are specified directly, this is required when checkTheta = FALSE
. Although assigning the names to each parameter is not necessary when checkTheta = TRUE
, it is advisable to ensure that the right values are assigned to the right parameter.
If argument checkTheta
is set to TRUE
, then the vector of theta
parameters is verified for consistency with the requirements of the model and shape selected.
3) Age-specific fertility models:
The age-specific fertility models correspond to the expected number of offspring produced by adults of a given age. Therefore, for a random variable with realizations
for the number of offspring produced by adults of age
, we have that
, where
is a non-negative smooth fertility function and
is a vector of parameters to be estimated. The functional forms of function
fall in two main categories, namely polynomial and distributional models.
3.a) Polynomial:
Of the models available in paramDemo
, the “quadratic
”, “PeristeraKostaki
” (Peristera and Kostaki 2007), and “ColcheroMuller
” (Colchero et al. 2021, Muller et al. 2020) fall within the polynomial category. Both, the “PeristeraKostaki
” and “ColcheroMuller
” are non-symmetric around the age at maximum fertility.
3.b) Distributional:
The distributional models are of the form
where is a probability density function,
is a parameter for the total fertility rate, and
is a vector of parameters. The
“
Hadwiger
” (Hadwiger 1940), “gamma
” (Hoem et al. 1981), “beta
” (Hoem et al. 1981), “skewNormal
” (Mazzuco and Scarpa 2011, 2015), “gammaMixture
” (Hoem et al. 1981), “HadwigerMixture
” (Chandola et al. 1991), “skewSymmetric
” (Mazzuco and Scarpa 2011, 2015), and “skewLogistic
” (Asili et al. 2014) all fall in this category. Notably, the “gammaMixture
”, “HadwigerMixture
”, “skewSymmetric
”, “skewLogistic
” are appropriate when fertility might be bimodal (Hoem et al. 1981, Chandola et al. 1999, Mazzuco and Scarpa 2011, 2015, Asili et al. 2014).
4) Specifiying beta parameters:
Argument beta
requires a vector of parameters. For instance, for a quadratic model with parameter vector where
,
and
, the argument should be specified as
CalcDemo(..., beta = c(b0 = 0.5, b1 = 0.01, b2 = 10), ...)
Note that in this example the parameter names are specified directly, this is required when checkBeta = FALSE
. Although assigning the names to each parameter is not necessary when checkBeta = TRUE
, it is advisable to ensure that the right values are assigned to the right parameter.
If argument checkBeta
is set to TRUE
, then the vector of beta
parameters is verified for consistency with the requirements of the fertility model selected.
5) Summary statistics:
5.1) Ageing rates:
Given a vector of ages specified by the user with argument
agesAR
, the function calculates ageing rates at age as
for .
5.2) Ages at different levels of survival:
The function calculates the ages when the survival function reaches specific values(default at 0.2, 0.1, 0.05), commonly used as population measures of old age. Thus, for a given value , the function computes the inverse function
5.3) Remaining life expectancy:
The function calculates the life expectancy at birth as
5.4) Measures of inequality and equality:
The function calculates different measures of inequality and equality in the distribution of ages at death that results from the parametric model:
- Lifespan inequality:
(Demetrius 1974, Keyfitz and Caswell 2005) given by
- Lifespan equality:
(Colchero et al. 2016, Colchero et al. 2021) given by
- Gini coefficient:
(Gini 1912, Shkolnikov et al. 2003) given by
- Coefficient of variation:
given by
where is the variance in ages at death.
CalcDemo
returns an object of class “paramDemo
” with output consisting of two lists, one for survival and one for fertility. The survival list can be called as object$surv
while the fertility list is in object$fert
. Both include the following outputs:
functs |
data.frame including the follwing columns for survival: |
summStats |
list with elements: |
settings |
list with the details of the parameters and the models used. |
analyzed |
logical indicating whether |
Fernando Colchero [email protected]
Asili S., Rezaei S., Najjar, L. (2014) Using Skew-Logistic Probability Density Function as a Model for Age-Specific Fertility Rate Pattern. BioMed Research International, 2014, 790294.
Azzalini, A. (1985) A Class of Distributions Which Includes the Normal Ones. Scandinavian Journal of Statistics, 2, 171-178.
Chandola, T., Coleman D.A., Hiorns R.W. (1999) Recent European fertility patterns: Fitting curves to ‘distorted’ distributions. Population Studies, 53, 317-329.
Colchero, F. (In prep.) Inference on age-specific fertility in ecology and evolution. Learning from other disciplines and improving the state of the art.
Colchero, F., Eckardt, W., Stoinski, T. (2021) Evidence of demographic buffering in an endangered great ape: Social buffering on immature survival and the role of refined sex-age classes on population growth rate. Journal of Animal Ecology, 90, 1701-1713.
Colchero, F., J.S. Clark (2012) Bayesian inference on age-specific survival from capture-recapture data for censored and truncated data. Journal of Animal Ecology. 81, 139-149.
Colchero, F., O.R. Jones, M. Rebke. (2012) BaSTA: an R package for Bayesian estimation of age-specific survival from incomplete mark-recapture/recovery data with covariates. Method in Ecology and Evolution. 3, 466-470.
Colchero, F., et al. (2021) The long lives of primates and the “invariant rate of aging” hypothesis. Nature Communications 12:3666
Cox, D. R., and Oakes D. (1984) Analysis of Survival Data. Chapman and Hall, London.
Demetrius, L. (1974) Demographic parameters and natural selection. PNAS 71, 4645-4647.
Gompertz, B. (1825) On the nature of the function expressive of the law of human mortality, and on a new mode of determining the value of life contingencies. Philosophical Transactions of the Royal Society of London, 115, 513-583.
Hadwiger, H. (1940) Eine analytische Reproduktionssunktion fur biologische Gesamtheiten. Scandinavian Actuarial Journal, 1940, 101-113.
Hoem, J.M., Madien, D., Nielsen, J.L., Ohlsen, E.M., Hansen, H.O., Rennermalm, B. (1981) Experiments in modelling recent Danish fertility curves. Demography, 18, 231-244.
Keyfitz, N., Caswell, H. (2005) Applied Mathematical Demography. (Springer-Verlag).
Makeham, W. M. (1866) On the law of mortality Journal of the Institute of Actuaries 13, 1-34.
Mazzuco, S., Scarpa, B. (2011) Fitting age-specific fertility rates by a skew- symmetric probability density function. (Working paper 10), University of Padua.
Mazzuco, S., Scarpa, B. (2015) Fitting age-specific fertility rates by a flexible generalized skew normal probability density function. Journal of the Royal Statistical Society: Series A, 178, 187-203.
Muller M. N., Blurton Jones N. G, Colchero F., Thompson M. E., Enigk D. K. (2020) Sexual dimorphism in chimpanzee (Pan troglodytes schweinfurthii) and human age-specific fertility. Journal of human evolution, 144, 102795.
Peristera P., Kostaki A. (2007) Modeling fertility in modern populations. Demographic Research, 16, 141-194.
Pinder III, J.E., Wiener, J.G. and Smith, M.H. (1978) The Weibull distribution: a new method of summarizing survivorship data. Ecology, 59, 175-179.
Shkolnikov, V., Andreev, E., Begun, A. Z. (2003) Gini coefficient as a life table function. Demographic Research 8, 305-358.
Siler W. A (1979) competing-risk model for animal mortality. Ecology 60, 750-757.
CalcSurv
to calculate age-specific survival, CalcMort
to calculate age-specific mortality, CalcFert
to calculate age-specific fertility.
CalcAgeingRateMort
to calculate ageing rates from parametric models of age-specific mortality. CalcRemainLifeExp
to calculate remaining life expectancy from parametric models of age-specific mortality. CalcAgeMaxFert
to calculate the age at maximum fertility from parametric models of age-specific fertility.
CalcLifeHist
to calculate life history variables from parametric demographic models.
# Create paramDemo object from Gompertz mortality and # quadratic fertility: dem <- CalcDemo(theta = c(b0 = -5, b1 = 0.1), beta = c(b0 = 0.5, b1 = 0.01, b2 = 10), summarStats = TRUE, agesAR = c(5, 10)) # Plot demographic object: plot(dem)
# Create paramDemo object from Gompertz mortality and # quadratic fertility: dem <- CalcDemo(theta = c(b0 = -5, b1 = 0.1), beta = c(b0 = 0.5, b1 = 0.01, b2 = 10), summarStats = TRUE, agesAR = c(5, 10)) # Plot demographic object: plot(dem)
CalcDiscrDemo
is used to calculate survival and fertility functions (i.e., lx
, px
, and qx
) on discrete age intervals from an object of class “paramDemo
” created with function CalcDemo
.
CalcDiscrDemo(demo, dx = 1)
CalcDiscrDemo(demo, dx = 1)
demo |
Object of class “ |
dx |
Numeric value for the age increments. Default is |
CalcDiscrDemo
takes the continuous survival functions from an object of class “paramDemo
” and calculates the basic survival probabilities and, if available, fertility rates on discrete age intervals.
Let and
be the next integer of the age when the survival function
reaches the minimum. Given the age increments,
, specified with argument
dx
, the function creates a partition of such that
for
. At each age interval it calculates the discrete survival,
lx
, as
The age- or stage-specific survival probability, px
, is calculated as
while the age- or stage-specific mortality probability, qx
, is .
If fertility was also calculated with function CalcDemo
, then the function includes the discrete age- or stage-specific fertility, bx
, as
where is the continuous fertility function.
CalcDiscrDemo
returns an object of class “discrDemo
” that consist of a matrix with the following columns:
age |
Partition of the full age subset into discrete intervals |
lx |
Survival or cumulative survival |
px |
The age- or stage-specific survival probability |
qx |
The age- or stage-specific mortality probability |
bx |
If available, the age- or stage-specific fertility |
Fernando Colchero [email protected]
CalcDemo
to create an object of class “paramDemo
”.
# Create paramDemo object from Gompertz mortality and # quadratic fertility: dem <- CalcDemo(theta = c(b0 = -5, b1 = 0.1), beta = c(b0 = 0.5, b1 = 0.01, b2 = 10), summarStats = TRUE, agesAR = c(5, 10)) # Create discrete demographic object: demDisc <- CalcDiscrDemo(dem, dx = 1)
# Create paramDemo object from Gompertz mortality and # quadratic fertility: dem <- CalcDemo(theta = c(b0 = -5, b1 = 0.1), beta = c(b0 = 0.5, b1 = 0.01, b2 = 10), summarStats = TRUE, agesAR = c(5, 10)) # Create discrete demographic object: demDisc <- CalcDiscrDemo(dem, dx = 1)
CalcFert
is used to calculate age-specific fertility from different parametric models.
CalcFert(beta, x, modelFert = "quadratic", checkBeta = TRUE)
CalcFert(beta, x, modelFert = "quadratic", checkBeta = TRUE)
beta |
Numerical vector of age-specific fertility parameters (see details). |
x |
Numerical vector of ages at which to calculate fertility. |
modelFert |
Age-specific fertility model. Options are “ |
checkBeta |
Logical to verify that the |
1) Age-specific fertility models:
The age-specific fertility models correspond to the expected number of offspring produced by adults of a given age. Therefore, for a random variable with realizations
for the number of offspring produced by adults of age
, we have that
, where
is a non-negative smooth fertility function and
is a vector of parameters to be estimated. The functional forms of function
fall in two main categories, namely polynomial and distributional models.
2.a) Polynomial:
Of the models available in paramDemo
, the “quadratic
”, “PeristeraKostaki
” (Peristera and Kostaki 2007), and “ColcheroMuller
” (Colchero et al. 2021, Muller et al. 2020) fall within the polynomial category. Both, the “PeristeraKostaki
” and “ColcheroMuller
” are non-symmetric around the age at maximum fertility.
2.b) Distributional:
The distributional models are of the form
where is a probability density function,
is a parameter for the total fertility rate, and
is a vector of parameters. The
“
Hadwiger
” (Hadwiger 1940), “gamma
” (Hoem et al. 1981), “beta
” (Hoem et al. 1981), “skewNormal
” (Mazzuco and Scarpa 2011, 2015), “gammaMixture
” (Hoem et al. 1981), “HadwigerMixture
” (Chandola et al. 1991), “skewSymmetric
” (Mazzuco and Scarpa 2011, 2015), and “skewLogistic
” (Asili et al. 2014) all fall in this category. Notably, the “gammaMixture
”, “HadwigerMixture
”, “skewSymmetric
”, “skewLogistic
” are appropriate when fertility might be bimodal (Hoem et al. 1981, Chandola et al. 1999, Mazzuco and Scarpa 2011, 2015, Asili et al. 2014).
2) Specifying beta parameters:
Argument beta
requires a vector of parameters. For instance, for a quadratic model with parameter vector , the argument should be specified as
theta = c(b0 = 0.5, b1 = 0.01, b2 = 10)
. Note that in this example the parameter names are specified directly, this is required when checkBeta = FALSE
. Although assigning the names to each parameter is not necessary when checkBeta = TRUE
, it is advisable to ensure that the right values are assigned to the right parameter.
If argument checkBeta
is set to TRUE
, then the vector of beta
parameters is verified for consistency with the requirements of the model and shape selected.
CalcFert
returns a vector of class “numeric
” with the fertility values at the specified ages.
Fernando Colchero [email protected]
Asili, S., Rezaei, S. & Najjar, L. (2014) Using Skew-Logistic Probability Density Function as a Model for Age-Specific Fertility Rate Pattern. BioMed Research International, 2014, 790294.
Azzalini, A. (1985) A Class of Distributions Which Includes the Normal Ones. Scandinavian Journal of Statistics, 2, 171-178.
Chandola, T., Coleman, D.A. & Hiorns, R.W. (1999) Recent European fertility patterns: Fitting curves to ‘distorted’ distributions. Population Studies, 53, 317-329.
Colchero, F. (In prep.) Inference on age-specific fertility in ecology and evolution. Learning from other disciplines and improving the state of the art.
Colchero, F., Eckardt, W. & Stoinski, T. (2021) Evidence of demographic buffering in an endangered great ape: Social buffering on immature survival and the role of refined sex-age classes on population growth rate. Journal of Animal Ecology, 90, 1701-1713.
Hadwiger, H. (1940) Eine analytische Reproduktionssunktion fur biologische Gesamtheiten. Scandinavian Actuarial Journal, 1940, 101-113.
Hoem, J.M., Madien, D., Nielsen, J.L., Ohlsen, E.M., Hansen, H.O. & Rennermalm, B. (1981) Experiments in modelling recent Danish fertility curves. Demography, 18, 231-244.
Mazzuco, S. & Scarpa, B. (2011) Fitting age-specific fertility rates by a skew- symmetric probability density function. (Working paper 10), University of Padua.
Mazzuco, S. & Scarpa, B. (2015) Fitting age-specific fertility rates by a flexible generalized skew normal probability density function. Journal of the Royal Statistical Society: Series A, 178, 187-203.
Muller, M. N., Blurton Jones, N. G, Colchero, F., Thompson, M. E., Enigk, D. K. (2020) Sexual dimorphism in chimpanzee (Pan troglodytes schweinfurthii) and human age-specific fertility. Journal of human evolution, 144, 102795.
Peristera, P. & Kostaki, A. (2007) Modeling fertility in modern populations. Demographic Research, 16, 141-194.
CalcMort
to calculate age-specific mortality, CalcSurv
to calculate age-specific survival
# Age specific fertility based on quadratic model (default): fert <- CalcFert(beta = c(b0 = 0.5, b1 = 0.01, b2 = 10), x = 10) # Age specific fertility based on gamma model: fert <- CalcFert(beta = c(b0 = 13, b1 = 2, b2 = 0.15), x = 10, modelFert = "gamma")
# Age specific fertility based on quadratic model (default): fert <- CalcFert(beta = c(b0 = 0.5, b1 = 0.01, b2 = 10), x = 10) # Age specific fertility based on gamma model: fert <- CalcFert(beta = c(b0 = 13, b1 = 2, b2 = 0.15), x = 10, modelFert = "gamma")
CalcLifeHist
uses parametric models of survival and fertility to calculate age-specific demographic rates, stable age structure, reproductive values, sensitivity and elasticities of the stable population growth rate to demographic rates, as well as different life history variables such as generation time or population entropy.
CalcLifeHist(theta = NULL, beta = NULL, dx = NULL, model = "GO", shape = "simple", modelFert = "quadratic", ageMatur = 0, maxAge = NULL, lambdaMethod = "matrix")
CalcLifeHist(theta = NULL, beta = NULL, dx = NULL, model = "GO", shape = "simple", modelFert = "quadratic", ageMatur = 0, maxAge = NULL, lambdaMethod = "matrix")
theta |
Numerical vector of age-specific mortality parameters (see details). |
beta |
Numerical vector of age-specific fertility parameters (see details). |
dx |
Numerical value for the age-interval increments, default is 1. |
model |
Mortality model, options are “ |
shape |
The overall shape of the mortality model. Values are: “ |
modelFert |
Age-specific fertility model. Options are “ |
ageMatur |
Numerical value for the age at maturity. |
maxAge |
Numerical value for the maximum age. If |
lambdaMethod |
Character string specifying the method to calculate the intrinsic population growth rate. Values are “ |
1) Age-specific mortality and survival models:
The function CalcDemo
uses parametric functions to calculate age-specific survival, defined as the probability of surviving to a given age. The function follows the conventions from package BaSTA (Colchero and Clark 2012, Colchero et al. 2012, Colchero et al. 2021). The mortality function describes how the risk of mortality changes with age, and is defined as
where is a random variable for ages at death,
are ages and
is the vector of mortality parameters. From the mortality function, the survival function is then given by
1.1)
Argument
“model
”:
The model
argument allows the user to choose between four basic mortality functions, namely
(a) model =
“EX
”: The exponential model (Cox and Oakes 1974), with constant mortality with age, specified as
where , with survival
(b) model =
“GO
”: The Gompertz mortality model (Gompertz 1925, Pletcher 1999), calculated as
where , with survival
(c) model =
“WE
”: The Weibull mortality model (Pinder III et al. 1978) calculated as
where , with survival
(d) model =
“LO
”: The logistic mortality model (Pletcher 1999), calculated as
where , with survival
1.2)
Argument
“shape
”:
The shape
argument allows the user to extend these models in order to explore more complex mortality shapes.
(a) shape =
“simple
”: (default) Leaves the model as defined above, with mortality given by
and survival
(b) shape =
“Makeham
”: A constant is added to the mortality, such that the mortality is given by
where , and with survival
The most common models with this shape is the Gompertz-Makeham model (Gompertz 1825, Makeham 1866).
(c) shape =
“bathtub
”: produces a concave shapes in mortality by adding a declining Gompertz term and a constant parameter to the basic mortality model, where the mortality function is
where ,
and
are specified based on argument
model
, and with survival
The most widely use “bathtub
” shaped model is the Siler mortality model (Siler 1979), which provides considerably good fits to mammalian data. The arguments for the Siler model are:
CalcLifeHist(..., model = "GO", shape = "bathtub", ...)
2) Specifying theta parameters:
Argument theta
requires a numerical vector of parameters. For instance, for a Gompertz model with simple shape and with parameter vector where
and
, the argument should be specified as
CalcDemo(theta = c(b0 = -5, b1 = 0.1), ...)
Note that in this example the parameter names are specified directly, this is required when checkTheta = FALSE
. Although assigning the names to each parameter is not necessary when checkTheta = TRUE
, it is advisable to ensure that the right values are assigned to the right parameter.
If argument checkTheta
is set to TRUE
, then the vector of theta
parameters is verified for consistency with the requirements of the model and shape selected.
3) Age-specific fertility models:
The age-specific fertility models correspond to the expected number of offspring produced by adults of a given age. Therefore, for a random variable with realizations
for the number of offspring produced by adults of age
, we have that
, where
is a non-negative smooth fertility function and
is a vector of parameters to be estimated. The functional forms of function
fall in two main categories, namely polynomial and distributional models.
3.a) Polynomial:
Of the models available in paramDemo
, the “quadratic
”, “PeristeraKostaki
” (Peristera and Kostaki 2007), and “ColcheroMuller
” (Colchero et al. 2021, Muller et al. 2020) fall within the polynomial category. Both, the “PeristeraKostaki
” and “ColcheroMuller
” are non-symmetric around the age at maximum fertility.
3.b) Distributional:
The distributional models are of the form
where is a probability density function,
is a parameter for the total fertility rate, and
is a vector of parameters. The
“
Hadwiger
” (Hadwiger 1940), “gamma
” (Hoem et al. 1981), “beta
” (Hoem et al. 1981), “skewNormal
” (Mazzuco and Scarpa 2011, 2015), “gammaMixture
” (Hoem et al. 1981), “HadwigerMixture
” (Chandola et al. 1991), “skewSymmetric
” (Mazzuco and Scarpa 2011, 2015), and “skewLogistic
” (Asili et al. 2014) all fall in this category. Notably, the “gammaMixture
”, “HadwigerMixture
”, “skewSymmetric
”, “skewLogistic
” are appropriate when fertility might be bimodal (Hoem et al. 1981, Chandola et al. 1999, Mazzuco and Scarpa 2011, 2015, Asili et al. 2014).
4) Specifiying beta parameters:
Argument beta
requires a vector of parameters. For instance, for a quadratic model with parameter vector where
,
and
, the argument should be specified as
CalcLifeHist(..., beta = c(b0 = 0.5, b1 = 0.01, b2 = 10), ...)
Note that in this example the parameter names are specified directly, this is required when checkBeta = FALSE
. Although assigning the names to each parameter is not necessary when checkBeta = TRUE
, it is advisable to ensure that the right values are assigned to the right parameter.
If argument checkBeta
is set to TRUE
, then the vector of beta
parameters is verified for consistency with the requirements of the fertility model selected.
5) Methods to estimate lambda, r, stable age structure and reproductive values:
If argument lambdaMethod
is set to “matrix
”, the function calculates the assymptotic population growth rate as the dominant eigen-value of the resulting population projection matrix
(Caswell and Wegner 1978, Kroon et al. 1986, Caswell 2001). The intrinsing population growth rate is then
, while the stable age-structure,
, where
is the maximum age of the population, is given by the corresponding right eigen vector, standardized by its norm. The reproductive value is the corresponding left eigen vector,
, standardized such that
.
If argument lambdaMethod
is set to “Lotka
”, the function estimates the intrinsic population growth rate, , by finding the real root of Lotka' (1913) equation, given by
The stable population structure is then calculated as
while the reproductive value is given by
The function then calculates the sensitivities of lambda to age-specific survival as
where the denominator is the inner product, and the sensitivity of lambda to the reproductive value at is given by
Elasticities are calculated as
6) Calculation of life history variables
The first life history variables are the intrinsic population growth rate and the stable population growth rate
, described in the previous section.
The function also provides a number of life history variables described by Tuljapurkar et al. (2009). For instance, it provides the generation time for the stable population as
as well as the cohort generation time, given by
where is the net reproductive rate, given by
It provides the demographic dispersion given by
which measures the dispersion of reproduction across ages.
Finally, it calculates the population entropy as proposed by Demetrius (1974), given by
where .
The function produces an object of class “PDlifeHist
”, which consists of a list with the following elements:
demoTab |
A data frame with the resulting individual ages, the survival |
lifeHist |
A data frame with the life history variables described in details, including a description. |
settings |
A list with the information of the models and parameters as provided by the user. |
Fernando Colchero [email protected]
Asili S., Rezaei S., Najjar, L. (2014) Using Skew-Logistic Probability Density Function as a Model for Age-Specific Fertility Rate Pattern. BioMed Research International, 2014, 790294.
Azzalini, A. (1985) A Class of Distributions Which Includes the Normal Ones. Scandinavian Journal of Statistics, 2, 171-178.
Caswell, H. & Werner, P. A. (1978) Transient Behavior and Life History Analysis of Teasel (Dipsacus Sylvestris Huds.). Ecology 59, 53-66.
Caswell, H. (2001) Matrix Population Models: Construction, Analysis and Interpretation. (Sinauer Associates).
Chandola, T., Coleman D.A., Hiorns R.W. (1999) Recent European fertility patterns: Fitting curves to ‘distorted’ distributions. Population Studies, 53, 317-329.
Colchero, F. (In prep.) Inference on age-specific fertility in ecology and evolution. Learning from other disciplines and improving the state of the art.
Colchero, F., Eckardt, W., Stoinski, T. (2021) Evidence of demographic buffering in an endangered great ape: Social buffering on immature survival and the role of refined sex-age classes on population growth rate. Journal of Animal Ecology, 90, 1701-1713.
Colchero, F., J.S. Clark (2012) Bayesian inference on age-specific survival from capture-recapture data for censored and truncated data. Journal of Animal Ecology. 81, 139-149.
Colchero, F., O.R. Jones, M. Rebke. (2012) BaSTA: an R package for Bayesian estimation of age-specific survival from incomplete mark-recapture/recovery data with covariates. Method in Ecology and Evolution. 3, 466-470.
Colchero, F., et al. (2021) The long lives of primates and the “invariant rate of aging” hypothesis. Nature Communications 12:3666
Cox, D. R., and Oakes D. (1984) Analysis of Survival Data. Chapman and Hall, London.
Demetrius, L. (1974) Demographic parameters and natural selection. PNAS 71, 4645-4647.
Gompertz, B. (1825) On the nature of the function expressive of the law of human mortality, and on a new mode of determining the value of life contingencies. Philosophical Transactions of the Royal Society of London, 115, 513-583.
Hadwiger, H. (1940) Eine analytische Reproduktionssunktion fur biologische Gesamtheiten. Scandinavian Actuarial Journal, 1940, 101-113.
Hoem, J.M., Madien, D., Nielsen, J.L., Ohlsen, E.M., Hansen, H.O., Rennermalm, B. (1981) Experiments in modelling recent Danish fertility curves. Demography, 18, 231-244.
Keyfitz, N., Caswell, H. (2005) Applied Mathematical Demography. (Springer-Verlag).
Kroon, H. de, Plaisier, A., Groenendael, J. van & Ecology, H. C. (1986) Elasticity: the relative contribution of demographic parameters to population growth rate. Ecology 67, 1427-1431.
Lotka, A. J. (1913) A natural population norm. II. Journal of the Washington Academy of Sciences 3, 289-293.
Makeham, W. M. (1866) On the law of mortality Journal of the Institute of Actuaries 13, 1-34.
Mazzuco, S., Scarpa, B. (2011) Fitting age-specific fertility rates by a skew- symmetric probability density function. (Working paper 10), University of Padua.
Mazzuco, S., Scarpa, B. (2015) Fitting age-specific fertility rates by a flexible generalized skew normal probability density function. Journal of the Royal Statistical Society: Series A, 178, 187-203.
Muller M. N., Blurton Jones N. G, Colchero F., Thompson M. E., Enigk D. K. (2020) Sexual dimorphism in chimpanzee (Pan troglodytes schweinfurthii) and human age-specific fertility. Journal of human evolution, 144, 102795.
Peristera P., Kostaki A. (2007) Modeling fertility in modern populations. Demographic Research, 16, 141-194.
Pinder III, J.E., Wiener, J.G. and Smith, M.H. (1978) The Weibull distribution: a new method of summarizing survivorship data. Ecology, 59, 175-179.
Shkolnikov, V., Andreev, E., Begun, A. Z. (2003) Gini coefficient as a life table function. Demographic Research 8, 305-358.
Siler W. A (1979) competing-risk model for animal mortality. Ecology 60, 750-757.
CalcDemo
to calculate parametric demographic functions.
# Calculate life histories on the defalult models: test <- CalcLifeHist(theta = c(b0 = -3, b1 = 0.1), beta = c(b0 = 1, b1 = 0.01, b2 = 5), ageMatur = 2) # Print results: test # Plot results: plot(test, type = "all")
# Calculate life histories on the defalult models: test <- CalcLifeHist(theta = c(b0 = -3, b1 = 0.1), beta = c(b0 = 1, b1 = 0.01, b2 = 5), ageMatur = 2) # Print results: test # Plot results: plot(test, type = "all")
CalcLifeTable
uses non-parametric methods to calculate life tables and confidence intervals.
CalcLifeTable(ageLast, ageFirst = NULL, departType, dx = 1, calcCIs = FALSE, nboot = 1000, alpha = 0.05)
CalcLifeTable(ageLast, ageFirst = NULL, departType, dx = 1, calcCIs = FALSE, nboot = 1000, alpha = 0.05)
ageLast |
Numerical vector with the ages at last detection (i.e., death and censoring) (see |
ageFirst |
Numerical vector of ages at first detection (i.e., truncation). If |
departType |
Character string vector for the type of departure (i.e., last detection), with values “ |
dx |
Age interval size, default set at 1 (see |
calcCIs |
Logical indicating whether confidence intervals should be calculated |
nboot |
Number of bootstrap iterations |
alpha |
Alpha level. Default is 0.05 for 95% CIs |
1) Data structure:
CalcLifeTable
allows to construct life tables for data that includes the following types of records:
Uncensored: individuals with known ages at death;
right-censored: individuals last seen alive;
left-truncated: individuals born before the start of the study and are truncated at the age of entry.
The data required are the ages at last detection (i.e., uncensored or right-censored) passed through argument “ageLast
”, the type of departure via argument “departType
”, which takes two values, namely “D
” for death, and “C
” for censored (i.e., right-censored).
In addition, if there is left-truncation, it takes the ages at entry to the study by means of argument “ageFirst
”. If all the individuals were born during the study, the value of “ageFirst
” can be left as NULL
, which will make them all equal to 0.
2) Computing life tables
To calculate life tables, the function uses conventional formal demgraphic methods as depicted by Preston et al. (2001). Argument “ageLast
” provides a vector of ages at last detection, , while argument “
ageFirst
” provides a vector of ages at first detection . From argument “
departType
” the function produces an indicator vector for censoring where
if individual
is censored and 0 otherwise.
The function creates a partition of the interval of ages between 0 and , for age intervals
where
is specified by argument “
dx
”. As default dx = 1
. At each age interval, the function calculates the following variables:
Nx
: which corresponds to number of individuals that entered the interval, but considering the proportion of time they were present within the interval as a function of left-truncation. It is given by
where is the subset of individuals recorded within the interval, and
is the proportion of time during the age interval each individual was present in the study. For individuals that entered the study before
then
, while for those that were truncated within the interval
.
Dx
: the number of individuals dying in the interval.
qx
: the age-specific mortality probability, calculated as .
px
: the age-specific survival probability, given by .
lx
: the life table survival calculated as
where .
ax
: Proportion of the interval lived by those that died in the interval, given by
where is the subset of individuals that died within the interval, and
is the proportion lived by those individuals from the start of the interval to their deaths, this is
.
Lx
: The number of individual years lived within the interval, given by
Tx
: The total number of individual years lived after age , given by
ex
: the remaining life expectancy at the beginning of each age interval, calculated as .
3) Calculating confidence intervals
If argument “calcCIs
” is set to TRUE
, the function uses a non-parametric bootstrap by sampling with replacement the data. Argument nboot
specifies the number of bootstrap steps, with default nboot = 2000
. From each re-sampled dataset, it uses function CalcLifeTable
to construct the corresponding life table and stores the values of $l_x$, $q_x$, $p_x$, and $e_x$ from each iteration. From these, it calculates quantiles at the given alpha level.
CalcLifeTable
returns an object of class “paramDemoLT
” with output consisting of a list with the life table and, if indicated by the user, with the confidence interval information. The life table in matrix format includes the following columns:
Ages |
Ages with increments given by |
Nx |
Number of individuals entering the interval, does not need to be an integer since it considers truncation |
Dx |
Number of individuals that died within the age interval |
lx |
Survival (i.e., cumulative survival) |
px |
Age-specific survival probability |
qx |
Age-specific mortality probability |
Lx |
Number of individual years lived within the interval |
Tx |
Number of individual years lived after age x |
ex |
Remaining life expectancy at each age |
If argument calcCIs = TRUE
, the function also returns a list containing the following components:
lx |
Matrix with Ages and mean and upper and lower CIs for the life table survival |
qx |
Matrix with Ages and mean and upper and lower CIs for the age-specific mortality probability |
px |
Matrix with Ages and mean and upper and lower CIs for the age-specific survival probability |
ex |
Matrix with Ages and mean and upper and lower CIs for the remaining life expectancy |
Settings |
Numerical vector including whether CIs were calculated, the number of bootstrap iterations, “ |
Fernando Colchero [email protected]
Preston, S.H., Heuveline, P. and Guillot, M. (2001) Demography: Measuring and Modeling Population Processes. Blackwell, Oxford.
CalcProductLimitEst
to calculate product limit estimators.
# Simulate age at death data from Gompertz model: ages <- SampleRandAge(n = 100, theta = c(b0 = -5, b1 = 0.1)) # Calculate life table: lt <- CalcLifeTable(ageLast = ages, departType = rep("D", 100)) # Calculate life table with 95% CIs: ltCIs <- CalcLifeTable(ageLast = ages, departType = rep("D", 100), calcCIs = TRUE, nboot = 100)
# Simulate age at death data from Gompertz model: ages <- SampleRandAge(n = 100, theta = c(b0 = -5, b1 = 0.1)) # Calculate life table: lt <- CalcLifeTable(ageLast = ages, departType = rep("D", 100)) # Calculate life table with 95% CIs: ltCIs <- CalcLifeTable(ageLast = ages, departType = rep("D", 100), calcCIs = TRUE, nboot = 100)
CalcMort
and CalcSurv
are used to calculate the age-specific mortality and survival functions from different parametric models.
CalcMort(theta, x, model = "GO", shape = "simple", checkTheta = TRUE) CalcSurv(theta, x, model = "GO", shape = "simple", checkTheta = TRUE)
CalcMort(theta, x, model = "GO", shape = "simple", checkTheta = TRUE) CalcSurv(theta, x, model = "GO", shape = "simple", checkTheta = TRUE)
theta |
Numerical vector of age-specific mortality parameters (see details). |
x |
Numerical vector of ages at which to calculate mortality. |
model |
The underlying mortality model to be used. |
shape |
The overall shape of the model. Values are: |
checkTheta |
Logical to verify that the |
1) Age-specific mortality and survival models:
The function CalcMort
uses parametric functions to calculate age-specific survival, defined as the probability of surviving to a given age. The function follows the conventions from package BaSTA (Colchero and Clark 2012, Colchero et al. 2012, Colchero et al. 2021). The mortality function or hazard rate describes how the risk of mortality changes with age, and is defined as
where is a random variable for ages at death,
are ages and
is the vector of mortality parameters. From the mortality function, the survival function is then given by
with the cumulative distribution function . The probability density function of ages at death is
for .
1.1)
Argument
“model
”:
The model
argument allows the user to choose between four basic mortality functions, namely
(a) model =
“EX
”: The exponential model (Cox and Oakes 1974), with constant mortality with age, specified as
where , with survival
(b) model =
“GO
”: The Gompertz mortality model (Gompertz 1925, Pletcher 1999), calculated as
where , with survival
(c) model =
“WE
”: The Weibull mortality model (Pinder III et al. 1978) calculated as
where , with survival
(d) model =
“LO
”: The logistic mortality model (Pletcher 1999), calculated as
where , with survival
1.2)
Argument
“shape
”:
The shape
argument allows the user to extend these models in order to explore more complex mortality shapes.
(a) shape =
“simple
”: (default) Leaves the model as defined above, with mortality given by
and survival
(b) shape =
“Makeham
”: A constant is added to the mortality, such that the mortality is given by
where , and with survival
The most common models with this shape is the Gompertz-Makeham model (Gompertz 1825, Makeham 1866).
(c) shape =
“bathtub
”: produces a concave shapes in mortality by adding a declining Gompertz term and a constant parameter to the basic mortality model, where the mortality function is
where ,
and
are specified based on argument
model
, and with survival
The most widely use “bathtub
” shaped model is the Siler mortality model (Siler 1979), which provides considerably good fits to mammalian data. The arguments for the Siler model are:
CalcMort(..., model = "GO", shape = "bathtub", ...)
2) Specifying theta parameters:
Argument theta
requires a numerical vector of parameters. For instance, for a Gompertz model with simple shape and with parameter vector where
and
, the argument should be specified as
CalcMort(theta = c(b0 = -5, b1 = 0.1), ...)
Note that in this example the parameter names are specified directly, this is required when checkTheta = FALSE
. Although assigning the names to each parameter is not necessary when checkTheta = TRUE
, it is advisable to ensure that the right values are assigned to the right parameter.
If argument checkTheta
is set to TRUE
, then the vector of theta
parameters is verified for consistency with the requirements of the model and shape selected.
CalcMort
and CalcSur
return a vector of class “numeric
” with the hazard rate or cumulative survival values at the specified ages, respectively.
Fernando Colchero [email protected]
Colchero, F. and J.S. Clark (2012) Bayesian inference on age-specific survival from capture-recapture data for censored and truncated data. Journal of Animal Ecology. 81, 139-149.
Colchero, F., O.R. Jones and M. Rebke. (2012) BaSTA: an R package for Bayesian estimation of age-specific survival from incomplete mark-recapture/recovery data with covariates. Method in Ecology and Evolution. 3, 466-470.
Colchero, F., et al. (2021) The long lives of primates and the "invariant rate of aging" hypothesis. Nature Communications 12:3666
Cox, D. R., and Oakes D. (1984) Analysis of Survival Data. Chapman and Hall, London.
Gompertz, B. (1825) On the nature of the function expressive of the law of human mortality, and on a new mode of determining the value of life contingencies. Philosophical Transactions of the Royal Society of London, 115, 513-583.
Makeham, W. M. On the law of mortality (1866). Journal of the Institute of Actuaries 13, 1-34.
Pinder III, J.E., Wiener, J.G. and Smith, M.H. (1978) The Weibull distribution: a new method of summarizing survivorship data. Ecology, 59, 175-179.
Siler, W. A (1979) competing-risk model for animal mortality. Ecology 60, 750-757.
CalcSurv
to calculate age-specific survival, CalcFert
to calculate age-specific fertility.
# Gompertz age specific mortality (default): mort <- CalcMort(theta = c(b0 = -5, b1 = 0.1), x = 10) # Siler age specific mortality: mort <- CalcMort(theta = c(a0 = -1, a1 = 1, c = 0.0001, b0 = -6, b1 = 0.15), x = 10, model = "GO", shape = "bathtub") # Gompertz age specific survival (default): surv <- CalcSurv(theta = c(b0 = -5, b1 = 0.1), x = 10) # Siler age specific survival: surv <- CalcSurv(theta = c(a0 = -1, a1 = 1, c = 0.0001, b0 = -6, b1 = 0.15), x = 10, model = "GO", shape = "bathtub")
# Gompertz age specific mortality (default): mort <- CalcMort(theta = c(b0 = -5, b1 = 0.1), x = 10) # Siler age specific mortality: mort <- CalcMort(theta = c(a0 = -1, a1 = 1, c = 0.0001, b0 = -6, b1 = 0.15), x = 10, model = "GO", shape = "bathtub") # Gompertz age specific survival (default): surv <- CalcSurv(theta = c(b0 = -5, b1 = 0.1), x = 10) # Siler age specific survival: surv <- CalcSurv(theta = c(a0 = -1, a1 = 1, c = 0.0001, b0 = -6, b1 = 0.15), x = 10, model = "GO", shape = "bathtub")
CalcProductLimitEst
uses non-parametric methods to calculate the product limit estimator and confidence intervals.
CalcProductLimitEst(ageLast, ageFirst = NULL, departType, calcCIs = FALSE, nboot = 1000, alpha = 0.05)
CalcProductLimitEst(ageLast, ageFirst = NULL, departType, calcCIs = FALSE, nboot = 1000, alpha = 0.05)
ageLast |
Numerical vector with the ages at last detection (i.e., death and censoring) (see |
ageFirst |
Numerical vector of ages at first detection (i.e., truncation). If |
departType |
Character string vector for the type of departure (i.e., last detection), with values “ |
calcCIs |
Logical indicating whether confidence intervals should be calculated |
nboot |
Number of bootstrap iterations |
alpha |
Alpha level. Default is 0.05 for 95% CIs |
1) Data structure:
The function allows to calculate product limit estimator (Wann et al. 1987) for data that includes the following types of records:
Uncensored: individuals with known ages at death;
right-censored: individuals last seen alive;
left-truncated: individuals born before the start of the study and are truncated at the age of entry.
The data required are the ages at last detection (i.e., uncensored or right-censored) passed through argument “ageLast
”, the type of departure via argument “departType
”, which takes two values, namely “D
” for death, and “C
” for censored (i.e., right-censored).
In addition, if there is left-truncation, it takes the ages at entry to the study by means of argument “ageFirst
”. If all the individuals were born during the study, the value of “ageFirst
” can be left as NULL
, which will make them all equal to 0.
CalcProductLimitEst
returns an object of class “paramDemoPLE
” with consists of a data frame and, if indicated by the user, the confidence interval of the PLE. The data frame includes the following numerical columns:
Ages |
ages when individuals died |
ple |
product limit estimator |
Lower |
If indicated with argument |
Lower |
If indicated with argument |
Fernando Colchero [email protected]
CalcLifeTable
to calculate life tables.
# Simulate age at death data from Gompertz model: ages <- SampleRandAge(n = 100, theta = c(b0 = -5, b1 = 0.1)) # Calculate life table: lt <- CalcLifeTable(ageLast = ages, departType = rep("D", 100))
# Simulate age at death data from Gompertz model: ages <- SampleRandAge(n = 100, theta = c(b0 = -5, b1 = 0.1)) # Calculate life table: lt <- CalcLifeTable(ageLast = ages, departType = rep("D", 100))
CalcRemainingLifeExp
calculates remaining life expectancy from parametric models of age-specific mortality.
CalcRemainLifeExp (theta, x = NULL, dx = NULL, xmax = NULL, atAllAges = FALSE, model = "GO", shape = "simple", checkTheta = TRUE)
CalcRemainLifeExp (theta, x = NULL, dx = NULL, xmax = NULL, atAllAges = FALSE, model = "GO", shape = "simple", checkTheta = TRUE)
theta |
Numerical vector of age-specific mortality parameters (see details). |
x |
Numerical vector of ages at which to calculate mortality. |
dx |
Numerical value for the width of age intervals used for integration. If |
xmax |
Numerical value for the maximum age. If |
atAllAges |
Logical to indicate whether ageing rates should be provided between ages 0 and |
model |
The underlying mortality model to be used. |
shape |
The overall shape of the model. Values are: |
checkTheta |
Logical to verify that the |
The function CalcAgeingRate
uses parametric functions to calculate the actuarial (i.e., survival) rate of ageing. The function follows the conventions from package BaSTA (Colchero and Clark 2012, Colchero et al. 2012, Colchero et al. 2021) to select the parametric model of mortality. The mortality function describes how the risk of mortality changes with age, and is defined as
where is a random variable for ages at death,
are ages and
is the vector of mortality parameters. From the mortality function, the survival function is then given by
(For further details on the mortality and survival models see CalcMort
).
Given a vector of ages specified by the user with argument
x
, the function calculates the remaining life expectancy at age as
for .
The function outputs a matrix with the ages from which remaining life expectancies were calculated, and the values for the remaining life expectancy.
Fernando Colchero [email protected]
CalcSurv
to calculate age-specific survival, CalcMort
to calculate age-specific mortality, CalcFert
to calculate age-specific fertility.
CalcAgeMaxFert
to calculate the age at maximum fertility from parametric models of age-specific fertility. CalcAgeingRateMort
to calculate ageing rates from parametric models of age-specific mortality.
# Calculate ageing rate from Gompertz model: rle <- CalcRemainLifeExp(theta = c(b0 = -5, b1 = 0.1), x = 10) # Calculate ageing rate from Siler model: rle <- CalcRemainLifeExp(theta = c(a0 = -1, a1 = 1, c = 0.0001, b0 = -6, b1 = 0.15), x = 10, model = "GO", shape = "bathtub")
# Calculate ageing rate from Gompertz model: rle <- CalcRemainLifeExp(theta = c(b0 = -5, b1 = 0.1), x = 10) # Calculate ageing rate from Siler model: rle <- CalcRemainLifeExp(theta = c(a0 = -1, a1 = 1, c = 0.0001, b0 = -6, b1 = 0.15), x = 10, model = "GO", shape = "bathtub")
Draw a plot of demographic functions produced with function CalcDemo
## S3 method for class 'paramDemo' plot(x, demofun = "all", ...)
## S3 method for class 'paramDemo' plot(x, demofun = "all", ...)
x |
Object of class “ |
demofun |
Character string for the demographic function to be ploted |
... |
Additional arguments passed to function |
No return value, called for plotting objects of class “paramDemo
”
Fernando Colchero [email protected]
CalcDemo
to calculate parametric demographic functions.
# Create paramDemo object from Gompertz mortality and # quadratic fertility: dem <- CalcDemo(theta = c(b0 = -5, b1 = 0.1), beta = c(b0 = 0.5, b1 = 0.01, b2 = 10), summarStats = TRUE, agesAR = c(5, 10)) # Plot demographic object: plot(dem)
# Create paramDemo object from Gompertz mortality and # quadratic fertility: dem <- CalcDemo(theta = c(b0 = -5, b1 = 0.1), beta = c(b0 = 0.5, b1 = 0.01, b2 = 10), summarStats = TRUE, agesAR = c(5, 10)) # Plot demographic object: plot(dem)
Draw a plot of demographic rates from a life table produced with function CalcLifeTable
or of product limit estimator produced with function CalcProductLimitEst
## S3 method for class 'paramDemoLT' plot(x, demorate = "lx", inclCIs = FALSE, ...) ## S3 method for class 'paramDemoPLE' plot(x, inclCIs = FALSE, ...)
## S3 method for class 'paramDemoLT' plot(x, demorate = "lx", inclCIs = FALSE, ...) ## S3 method for class 'paramDemoPLE' plot(x, inclCIs = FALSE, ...)
x |
Object of class |
demorate |
Demographic rate to be plotted, choices are “ |
inclCIs |
Logical indicating whether confidence intervals should be ploted in case they were calculated with function |
... |
Additional arguments passed to function |
No return value, called for plotting objects of class “paramDemoLT
”
Fernando Colchero [email protected]
CalcLifeTable
to calculate life tables. CalcProductLimitEst
to calculate product limit estimators.
# Simulate age at death data from Gompertz model: ages <- SampleRandAge(n = 100, theta = c(b0 = -5, b1 = 0.1)) # Calculate life table: lt <- CalcLifeTable(ageLast = ages, departType = rep("D", 100)) # Plot life table: plot(lt)
# Simulate age at death data from Gompertz model: ages <- SampleRandAge(n = 100, theta = c(b0 = -5, b1 = 0.1)) # Calculate life table: lt <- CalcLifeTable(ageLast = ages, departType = rep("D", 100)) # Plot life table: plot(lt)
These functions are all generic methods for class PDlifeHist
.
## S3 method for class 'PDlifeHist' plot(x, type = "rates", ...) ## S3 method for class 'PDlifeHist' summary(object, ...) ## S3 method for class 'PDlifeHist' print(x, ...)
## S3 method for class 'PDlifeHist' plot(x, type = "rates", ...) ## S3 method for class 'PDlifeHist' summary(object, ...) ## S3 method for class 'PDlifeHist' print(x, ...)
x |
Object of class “ |
object |
Object of class “ |
type |
Character string specifying the type of plot to be drawn, options are “ |
... |
Additional arguments passed to functions |
For objects of class “PDlifeHist
”, function print
displays on the console the data frame of life history variables produced by function CalcLifeHist
.
Function summary
prints to the console, first the settings as specified by the user (i.e., theta
and beta
parameters, and the types of models used), and then, as function print
, the table of life history variables.
Function plot
with argument type
= “rates
” produces plots of the age-specific demographic rates (i.e., and
) and the stable age structure and reproductive values (i.e.,
and
). If argument
type
= “sensitivity
”, then it produces plots of the sensitivities and elasticities of to
and
.
No return value, called for plotting objects of class “PDlifeHist
”
Fernando Colchero [email protected]
CalcLifeHist
to calculate life history variables from parametric demographic models.
# Calculate life histories on the defalult models: test <- CalcLifeHist(theta = c(b0 = -3, b1 = 0.1), beta = c(b0 = 1, b1 = 0.01, b2 = 5), ageMatur = 2) # Print results: test # Summary: summary(test) # Plot results: plot(test, type = "all")
# Calculate life histories on the defalult models: test <- CalcLifeHist(theta = c(b0 = -3, b1 = 0.1), beta = c(b0 = 1, b1 = 0.01, b2 = 5), ageMatur = 2) # Print results: test # Summary: summary(test) # Plot results: plot(test, type = "all")
SampleRandAge
is used to randomly sample ages at death from a parametric mortality model
SampleRandAge(n, theta, dx = 0.001, model = "GO", shape = "simple", minSx = 1e-04)
SampleRandAge(n, theta, dx = 0.001, model = "GO", shape = "simple", minSx = 1e-04)
n |
Number of individual ages at death to sample |
theta |
Numerical vector of age-specific mortality parameters (see details). |
dx |
Numeric value for the age increments (see details). |
model |
The underlying mortality model to be used. |
shape |
The overall shape of the model. Values are: |
minSx |
Minimum value for the survival function to set the maximum age (see details) |
SampleRandAge
arguments “model
” and “shape
”, to calculate the survival function, for
, at discrete age intervals
where
is specfied with argument “
dx
”. It then calculates the CDF of ages at death, , and uses inverse sampling to sample
ages at death by random sampling from a uniform distribution bound as
where and
. It then finds the corresponding ages at death as
In most cases, this is acheived numerically and thus the lower the value for argument “dx
” the higher the precision.
SampleRandAge
returns a vector of class “numeric
” with randmly generated ages at death.
Fernando Colchero [email protected]
# Simulate age at death data from Gompertz model: ages <- SampleRandAge(n = 100, theta = c(b0 = -5, b1 = 0.1)) # Simulate age at death data from Siler model: ages <- SampleRandAge(n = 100, theta = c(a0 = 0, a1 = 1, c = 0.001, b0 = -5, b1 = 0.1), model = "GO", shape = "bathtub")
# Simulate age at death data from Gompertz model: ages <- SampleRandAge(n = 100, theta = c(b0 = -5, b1 = 0.1)) # Simulate age at death data from Siler model: ages <- SampleRandAge(n = 100, theta = c(a0 = 0, a1 = 1, c = 0.001, b0 = -5, b1 = 0.1), model = "GO", shape = "bathtub")