SL.flexsurv: Accelerated failure time models

Description Usage Arguments Value Examples

View source: R/SL.flexsurv.R

Description

This function implements accelerated failure time regression models to estimate the conditional survival, which is back-transformed to estimate the conditional mean. It leverages the flexsurv package to fit accelerated failure time models and uses numerical integration to back-transform. The numerical integration step can be unstable and we have tried to build in checks to guard against this. In particular, we first try to integrate with upper limit = Inf, but if that fails move to 1e8, which sometimes is able to provide a sane answer when upper limit = Inf fails. The function keeps trying smaller and smaller values, but will not go smaller than 1e6. In that case it returns a random number between 0 and randomUpper (default is maxY).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
SL.flexsurv(
  Y,
  X,
  newX,
  family,
  obsWeights,
  dist = "gengamma",
  randomUpper = max(Y),
  ...
)

Arguments

Y

A numeric outcome variable

X

A data.frame of covariates constituting the training sample

newX

A data.frame with the same column names and format as X constituting the validation sample.

family

Gaussian only

obsWeights

Observation-level weights (not currently used)

dist

Distribution for accelerated failure time model (defaults to generalized Gamma)

randomUpper

If numeric integration fails, for the purposes of stability while fitting the SuperLearner, a random number is selected uniformly between 0 and randomUpper (defaults to max(Y)).

Value

pred

Predicted outcomes based on predictors in newX

fit

A list with named entries object (the fitted flexsurv model object), randomUpper.

Examples

1
2
3
4
5
6
7
# load cost data
data(cost_data)
# fit AFT model
fit_flexsurv <- SL.flexsurv(Y = cost_data$totalcost, X = cost_data[, c("female", "race")],
                              newX = cost_data[, c("female", "race")])
# get back predictions
pred_flexsurv <- predict(fit_flexsurv$fit, newdata = cost_data[,c("female", "race")])

wuziyueemory/twostageSL documentation built on Oct. 19, 2020, 3:45 p.m.