erl | R Documentation |
These functions compute survival functions from a set of mortality and
disease incidence rates in an illness-death model. Expected residual
life time can be computed under various scenarios by the erl
function, and areas between survival functions can be computed under
various scenarios by the yll
function. Rates are assumed
supplied for equidistant intervals of length int
.
surv1( int, mu , age.in = 0, A = NULL )
erl1( int, mu , age.in = 0 )
surv2( int, muW, muD, lam, age.in = 0, A = NULL )
erl( int, muW, muD, lam=NULL, age.in = 0, A = NULL,
immune = is.null(lam), yll=TRUE, note=TRUE )
yll( int, muW, muD, lam=NULL, age.in = 0, A = NULL,
immune = is.null(lam), note=TRUE )
int |
Scalar. Length of intervals that rates refer to. |
mu |
Numeric vector of mortality rates at midpoints of intervals of length |
muW |
Numeric vector of mortality rates among persons in the "Well" state at
midpoints of intervals of length |
muD |
Numeric vector of mortality rates among persons in the "Diseased" state
at midpoints of intervals of length |
lam |
Numeric vector of disease incidence rates among persons in the "Well" state
at midpoints of intervals of length |
age.in |
Scalar indicating the age at the left endpoint of the first interval. |
A |
Numeric vector of conditioning ages for calculation of survival functions. |
immune |
Logical. Should the years of life lost to the disease be computed
using assumptions that non-diseased individuals are immune to the
disease ( |
note |
Logical. Should a warning of silly assumptions be printed? |
yll |
Logical. Should years of life lost be included in the result? |
The mortality rates given are supposed to refer to the ages
age.in+(i-1/2)*int
, i=1,2,3,...
.
The units in which int
is given must correspond to the units in
which the rates mu
, muW
, muD
and lam
are
given. Thus if int
is given in years, the rates must be given
in the unit of events per year.
The ages in which the survival curves are computed are from
age.in
and then at the end of length(muW)
(length(mu)
) intervals each of length int
.
The age.in
argument is merely a device to account for rates
only available from a given age. It has two effects, one is that
labeling of the interval endpoint is offset by this quantity, thus
starting at age.in
, and the other that the conditioning ages
given in the argument A
will refer to the ages defined by this.
The immune
argument is FALSE
whenever the disease
incidence rates are supplied. If set to TRUE
, the years of life
lost is computed under the assumption that individuals without the
disease at a given age are immune to the disease in the sense that the
disease incidence rate is 0, so transitions to the diseased state
(with presumably higher mortality rates) are assumed not to
occur. This is a slightly peculiar assumption (but presumably the most
used in the epidemiological literature) and the resulting object is
therefore given an attribute, NOTE
, that point this out.
If however muW
is the total mortality in the population
(including the diseased) the result is a good approximation to the
correct YLL.
The default of the surv2
function is to take the possibility of
disease into account.
surv1
and surv2
return a matrix whose first column
is the ages at the ends of the
intervals, thus with length(mu)+1
rows. The following columns
are the survival functions (since age.in
), and conditional on
survival till ages as indicated in A
, thus a matrix with
length(A)+2
columns. Columns are labeled with the actual
conditioning ages; if A
contains values that are not among the
endpoints of the intervals used, the nearest smaller interval border
is used as conditioning age, and columns are named accordingly.
surv1
returns the survival function for a simple model with one
type of death, occurring at intensity mu
.
surv2
returns the survival function for a person in the "Well"
state of an illness-death model, taking into account that the person
may move to the "Diseased" state, thus requiring all three transition
rates to be specified. The conditional survival functions are
conditional on being in the "Well" state at ages given in A
.
erl1
returns a three column matrix with columns age
,
surv
(survival function) and erl
(expected residual life
time) with length(mu)+1
rows.
erl
returns a two column matrix, columns labeled "Well" and
"Dis", and with row-labels A
. The entries are the expected
residual life times given survival to A
. If yll=TRUE
the
difference between the columns is added as a
third column, labeled "YLL".
Bendix Carstensen, b@bxc.dk
ci.cum
library( Epi )
data( DMlate )
# Naive Lexis object
Lx <- Lexis( entry = list( age = dodm-dobth ),
exit = list( age = dox -dobth ),
exit.status = factor( !is.na(dodth), labels=c("DM","Dead") ),
data = DMlate )
# Cut follow-up at insulin inception
Lc <- cutLexis( Lx, cut = Lx$doins-Lx$dob,
new.state = "DM/ins",
precursor.states = "DM" )
summary( Lc )
# Split in small age intervals
Sc <- splitLexis( Lc, breaks=seq(0,120,2) )
summary( Sc )
# Overview of object
boxes( Sc, boxpos=TRUE, show.BE=TRUE, scale.R=100 )
# Knots for splines
a.kn <- 2:9*10
# Mortality among DM
mW <- glm( lex.Xst=="Dead" ~ Ns( age, knots=a.kn ),
offset = log(lex.dur),
family = poisson,
data = subset(Sc,lex.Cst=="DM") )
# Mortality among insulin treated
mI <- update( mW, data = subset(Sc,lex.Cst=="DM/ins") )
# Total motality
mT <- update( mW, data = Sc )
# Incidence of insulin inception
lI <- update( mW, lex.Xst=="DM/ins" ~ . )
# From these we can now derive the fitted rates in intervals of 1 year's
# length. In real applications you would use much smaller interval like
# 1 month:
# int <- 1/12
int <- 1
# Prediction frame to return rates in units of cases per 1 year
# - we start at age 40 since rates of insulin inception are largely
# indeterminate before age 40
nd <- data.frame( age = seq( 40+int, 110, int ) - int/2,
lex.dur = 1 )
muW <- predict( mW, newdata = nd, type = "response" )
muD <- predict( mI, newdata = nd, type = "response" )
lam <- predict( lI, newdata = nd, type = "response" )
# Compute the survival function, and the conditional from ages 50 resp. 70
s1 <- surv1( int, muD, age.in=40, A=c(50,70) )
round( s1, 3 )
s2 <- surv2( int, muW, muD, lam, age.in=40, A=c(50,70) )
round( s2, 3 )
# How much is YLL overrated by ignoring insulin incidence?
round( YLL <- cbind(
yll( int, muW, muD, lam, A = 41:90, age.in = 40 ),
yll( int, muW, muD, lam, A = 41:90, age.in = 40, immune=TRUE ) ), 2 )[seq(1,51,10),]
par( mar=c(3,3,1,1), mgp=c(3,1,0)/1.6, bty="n", las=1 )
matplot( 40:90, YLL,
type="l", lty=1, lwd=3,
ylim=c(0,10), yaxs="i", xlab="Age" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.