calc.LL {cuRe} | R Documentation |
Loss of lifetime estimation
Description
Function for computing mean residual lifetime and loss of lifetime estimates based on relative survival models.
Usage
calc.LL(
object,
newdata = NULL,
type = c("ll", "mrl"),
time = NULL,
tau = 100,
var.type = c("ci", "se", "n"),
exp.fun = NULL,
ratetable = cuRe::survexp.dk,
rmap,
smooth.exp = FALSE,
scale = ayear,
pars = NULL,
n = 100
)
Arguments
object |
Fitted model to do predictions from. Possible classes are
|
newdata |
Data frame from which to compute predictions. If empty, predictions are made on the the data which the model was fitted on. |
type |
Type of life expectation estimate.
Possible values are |
time |
Time points at which to compute predictions. If empty, a grid of 100 time points between 0
and |
tau |
The upper limit of the integral (see details). Default is 100. |
var.type |
Character. Possible values are " |
exp.fun |
Object of class |
ratetable |
Object of class |
rmap |
List to be passed to |
smooth.exp |
Logical. If |
scale |
Numeric. Passed to the |
pars |
A vector of parameter values for the model given in |
n |
Number of knots used for the Gauss-Legendre quadrature. |
Details
The mean residual lifetime function and loss of lifetime function are based on numerical
integration of the area under the observed and expected conditional survival functions.
If type = "ll"
, the function computes
\frac{\int_t^\infty S^*(u)}{S^*(t)} - \frac{\int_t^\infty S(u)}{S(t)}.
If type = "mrl"
, the function computes
\frac{\int_t^\infty S(u)}{S(t)},
for a given t. The function S^*(t)
is the general population survival function and S(t)
is the observed survival function. Integration to infinity is not required in studies of human mortality,
so an upper limit, tau
, is chosen instead. As most humans die before they 100 years, this is
the default setting of the function. The integral is computed by Gauss-Legendre quadrature
and the point wise variance is estimated using the delta method and numerical differentiation.
Value
An object of class le
containing the life expectancy estimates
of each individual in newdata
.
Examples
##Use data cleaned version of the colon cancer data from the rstpm2 package
data("colonDC")
set.seed(2)
colonDC <- colonDC[sample(1:nrow(colonDC), 1000), ]
##Extract general population hazards
colonDC$bhaz <- general.haz(time = "FU", rmap = list(age = "agedays", sex = "sex", year= "dx"),
data = colonDC, ratetable = survexp.dk)
##Spline-base cure model
#Fit cure model
fit <- rstpm2::stpm2(Surv(FUyear, status) ~ 1, data = colonDC,
df = 6, bhazard = colonDC$bhaz, cure = TRUE)
#Compute and plot the loss of lifetime function
res <- calc.LL(fit, time = seq(0, 20, length.out = 50),
rmap = list(age = agedays, sex = sex, year = dx),
var.type = "n")
plot(res)
#Compute and plot the mean residual lifetime
res <- calc.LL(fit, time = seq(0, 20, length.out = 50), type = "mrl",
rmap = list(age = agedays, sex = sex, year = dx),
var.type = "n")
plot(res)
#Simple parametric cure model
#Fit cure model
fit <- fit.cure.model(Surv(FUyear, status) ~ 1, data = colonDC, bhazard = "bhaz",
type = "mixture", dist = "weibull", link = "logit")
#Compute and plot the loss of lifetime function
res <- calc.LL(fit, time = seq(0, 20, length.out = 50),
rmap = list(age = agedays, sex = sex, year = dx),
var.type = "n")
plot(res)
#Compute and plot the mean residual lifetime
res <- calc.LL(fit, time = seq(0, 20, length.out = 50), type = "mrl",
rmap = list(age = agedays, sex = sex, year = dx),
var.type = "n")
plot(res)