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
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
1 2 3 4 5 6 7 8
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 )
Scalar. Length of intervals that rates refer to.
Numeric vector of mortality rates at midpoints of intervals of length
Numeric vector of mortality rates among persons in the "Well" state at
midpoints of intervals of length
Numeric vector of mortality rates among persons in the "Diseased" state
at midpoints of intervals of length
Numeric vector of disease incidence rates among persons in the "Well" state
at midpoints of intervals of length
Scalar indicating the age at the left endpoint of the first interval.
Numeric vector of conditioning ages for calculation of survival functions.
Logical. Should the years of life lost to the disease be computed
using assumptions that non-diseased individuals are immune to the
Logical. Should a warning of silly assumptions be printed?
Logical. Should years of life lost be included in the result?
The mortality rates given are supposed to refer to the ages
The units in which
int is given must correspond to the units in
which the rates
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(mu)) intervals each of length
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
age.in, and the other that the conditioning ages
given in the argument
A will refer to the ages defined by this.
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.
muW is the total mortality in the population
(including the diseased) the result is a good approximation to the
The default of the
surv2 function is to take the possibility of
disease into account.
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
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
erl1 returns a three column matrix with columns
surv (survival function) and
erl (expected residual life
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
difference between the columns is added as a
third column, labeled "YLL".
Bendix Carstensen, firstname.lastname@example.org
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
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.