Learn R Programming

ilc (version 1.0)

extract.deaths: Miscellaneous utility functions for demogdata type mortality data

Description

This function calculates and outputs the corresponding (observed) number of deaths from a demogdata type mortality data for a choice of ages and calendar years.

Usage

extract.deaths(data, ages = data$age, years = data$year, combine.upper = T, fill.method = NULL, series = names(data$rate)[1])

Arguments

data
mortality data object of demogdata class
ages
vector of ages to extract
years
vector of years to extract
combine.upper
logical, if TRUE, ages above max(ages) will be grouped together
fill.method
string value indicating the method to be used for correcting missing or 0 transition rates before estimating the number of deaths (e.g. one of "perks", "interpolate" or "mspline"). By default is set to NULL, which corresponds to no data correction.
series
target series name (e.g. 'males') or index number (e.g. 1) of the data object to be extracted

Value

A 'fictive' demogdata class object in which the (mortality) rate component is replaced by the extracted number of deaths.

See Also

insp.dd, extract.ages, extract.years

Examples

Run this code
# 'observed' number of deaths (i.e. no data correction)
extract.deaths(dd.cmi.pens, ages=55:100)
# number of deaths with corrections using Perks mortality model
tmp.d <- extract.deaths(dd.cmi.pens, ages=55:100, fill='perks')
# Note: to further improve the plot the user can change the vertical
# axis label and/or main title (amongst other plotting parameters).
plot(tmp.d, transf=FALSE, ylab='Number of Deaths')    # change ylab
plot_dd(tmp.d, transf=FALSE, ylab='Number of Deaths', lpar=list(x.int=-0.2, y.int=0.9, cex=0.85))
plot_dd(tmp.d, y=1995:2003, transf=FALSE, lty=1:5, ylab='Number of Deaths',
  main=paste(tmp.d$lab, ": male (1995-2003)", sep='')) # change main title

Run the code above in your browser using DataLab