calc.Crude: Crude event probabilities

View source: R/calc.Crude.R

calc.CrudeR Documentation

Crude event probabilities

Description

Function for computing crude event probabilties based on relative survival models.

Usage

calc.Crude(
  object,
  newdata = NULL,
  type = c("disease", "other", "condother"),
  time = NULL,
  tau = 100,
  reverse = FALSE,
  var.type = c("ci", "se", "n"),
  exp.fun = NULL,
  ratetable = cuRe::survexp.dk,
  rmap,
  scale = ayear,
  smooth.exp = FALSE,
  pars = NULL,
  link = "loglog",
  n = 100
)

Arguments

object

Fitted model to do predictions from. Possible classes are gfcm, cm, stpm2, and pstpm2.

newdata

Data frame from which to compute predictions. If empty, predictions are made on the the data which the model was fitted on.

type

Probability to compute. Possible values are disease (default), other, and condother (see details).

time

Time points at which to compute predictions. If empty, a grid of 100 time points between 0 and tau is selected.

tau

Upper bound of the integral used to compute the probability of disease-related death (see details). The argument is only used for type = condother. Default is 100.

reverse

Logical. If TRUE, 1 - probability is provided (default is FALSE). Only applicable for type = condother.

var.type

Character. Possible values are "ci" (default) for confidence intervals, "se" for standard errors, and "n" for neither.

exp.fun

Object of class list containing functions for the expected survival of each row in newdata. If not specified, the function computes the expected survival based on newdata using the survival::survexp function. If newdata is not provided, the expected survival is based on the data which the model was fitted on.

ratetable

Object of class ratetable used to compute the general population survival. Default is survexp.dk.

rmap

List to be passed to survexp from the survival package if exp.fun = NULL. Detailed documentation on this argument can be found by ?survexp.

scale

Numeric. Passed to the survival::survexp function and defaults to 365.24. That is, the time scale is assumed to be in years.

smooth.exp

Logical. If TRUE, the general population survival function is smoothed by the function smooth.spline using the the argument all.knots = TRUE.

pars

A vector of parameter values for the model given in object. Currently not used.

link

Link function for computing variance in order to restrict confidence intervals to [0, 1]. Default is loglog.

n

Number of knots used for the Gauss-Legendre quadrature.

Details

The function estimates crude probabilities by using the relative survival, expected survival, and the cause-specific hazard function. The crude cumulative incidence of disease-related death (type = "disease") is

P(T \leq t, D = disease) = \int_0^t S^*(u) R(u) \lambda(u)du.

The crude cumulative incidence of death from other causes (type = "other") is

P(T \leq t, D = other) = \int_0^t S^*(u) R(u) h^*(u)du.

The conditional probability of eventually dying from other causes than disease (type = "condother") is

P(D = other| T > t) = \frac{P(D = disease) - P(T \leq t, D = disease)}{P(T > t)}.

The probability of disease-related death, P(D = disease), can be computed by using type = "disease" and choosing a sufficiently large time point. For P(D = other| T>t), the argument tau controls this time point (default is 100).

Value

A list containing the crude probability estimates of each individual in newdata.

Examples

##Use data cleaned version of the colon disease 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 the probability of disease-related death
res <- calc.Crude(fit, time = seq(0, 20, length.out = 50),
                  rmap = list(age = agedays, sex = sex, year = dx),
                  var.type = "n")
plot(res)

#Compute the conditional probability of dying from other causes than disease
res <- calc.Crude(fit, time = seq(0, 20, length.out = 50), type = "condother",
                  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 the probability of disease-related death
res <- calc.Crude(fit, time = seq(0, 20, length.out = 50),
                  rmap = list(age = agedays, sex = sex, year = dx),
                  var.type = "n")
plot(res)

#Compute the conditional probability of disease-related death
res2 <- calc.Crude(fit, time = seq(0, 20, length.out = 50), type = "condother",
                  rmap = list(age = agedays, sex = sex, year = dx), reverse = TRUE,
                  var.type = "n")
plot(res2)

cuRe documentation built on July 9, 2023, 7 p.m.

Related to calc.Crude in cuRe...