Skip to contents

Flexible parametric learner. Calls flexsurv::flexsurvreg() from flexsurv.

Dictionary

This Learner can be instantiated via lrn():

lrn("surv.flexreg")

Meta Information

  • Task type: “surv”

  • Predict Types: “crank”, “distr”, “lp”, “response”

  • Feature Types: “logical”, “integer”, “numeric”, “factor”

  • Required Packages: mlr3, mlr3proba, mlr3extralearners, flexsurv, survival

Parameters

IdTypeDefaultLevelsRange
formulauntyped--
ancuntyped--
bhazarduntyped--
rtruncuntyped--
distcharacter-gengamma, gengamma.orig, genf, genf.orig, weibull, weibullph, gamma, exp, exponential, llogis, ...-
initsuntyped--
fixedparsuntyped--
clnumeric0.95\([0, 1]\)
hessianlogicalTRUETRUE, FALSE-
hess.controluntyped--
maxiterinteger30\((-\infty, \infty)\)
rel.tolerancenumeric1e-09\((-\infty, \infty)\)
toler.cholnumeric1e-10\((-\infty, \infty)\)
debuginteger0\([0, 1]\)
outer.maxinteger10\((-\infty, \infty)\)
timesuntyped--

Prediction types

This learner returns three prediction types:

  1. lp: a vector containing the linear predictors (relative risk scores), where each score corresponds to a specific test observation. Calculated using predict.flexsurvreg(type = "lp", ...). The interpretation whether higher lp corresponds to higher risk or higher survival, depends on the distribution choice (see dist parameter documentation).

  2. distr: a survival matrix in two dimensions, where observations are represented in rows and time points in columns. Calculated using predict.flexsurvreg(type = "survival", ...).

  3. crank: same as lp.

  4. response: mean survival time calculated using predict.flexsurvreg(type = "response", ...).

References

Jackson, H. C (2016). “flexsurv: A Platform for Parametric Survival Modeling in R.” Journal of Statistical Software, 70(8), 1–33. doi:10.18637/JSS.V070.I08 , https://www.jstatsoft.org/index.php/jss/article/view/v070i08.

See also

Author

bblodfon

Super classes

mlr3::Learner -> mlr3proba::LearnerSurv -> LearnerSurvFlexReg

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerSurvFlexReg$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

library(survival)

# Define the task, split to train/test set
task = tsk("lung")
set.seed(42)
part = partition(task)

# Define the learner
learner = lrn("surv.flexreg",
  formula = survival::Surv(time, status) ~ age + ph.karno + sex,
  anc = list(shape = ~ sex), dist = "weibull")

# Train the learner on the training ids
learner$train(task, part$train)
print(learner$model)
#> Call:
#> flexsurv::flexsurvreg(formula = form, anc = list(shape = ~sex), 
#>     data = task$data(), dist = "weibull", sr.control = list(iter.max = 30, 
#>         rel.tolerance = 1e-09, toler.chol = 1e-10, debug = 0, 
#>         maxiter = 30, outer.max = 10))
#> 
#> Estimates: 
#>              data mean  est        L95%       U95%       se         exp(est) 
#> shape               NA   1.71e+00   1.23e+00   2.39e+00   2.92e-01         NA
#> scale               NA   5.69e+02   7.83e+01   4.14e+03   5.76e+02         NA
#> age           6.34e+01  -5.94e-03  -2.52e-02   1.34e-02   9.85e-03   9.94e-01
#> ph.karno      8.23e+01   3.50e-03  -9.80e-03   1.68e-02   6.79e-03   1.00e+00
#> sexm          6.19e-01  -3.40e-01  -6.60e-01  -1.98e-02   1.63e-01   7.12e-01
#> shape(sexm)   6.19e-01  -2.61e-01  -6.62e-01   1.39e-01   2.04e-01   7.70e-01
#>              L95%       U95%     
#> shape               NA         NA
#> scale               NA         NA
#> age           9.75e-01   1.01e+00
#> ph.karno      9.90e-01   1.02e+00
#> sexm          5.17e-01   9.80e-01
#> shape(sexm)   5.16e-01   1.15e+00
#> 
#> N = 113,  Events: 80,  Censored: 33
#> Total time at risk: 34858
#> Log-likelihood = -555.8109, df = 6
#> AIC = 1123.622
#> 

# Make predictions for the test rows
predictions = learner$predict(task, part$test)
print(predictions)
#> 
#> ── <PredictionSurv> for 55 observations: ───────────────────────────────────────
#>  row_ids time status     crank        lp response     distr
#>        7  166   TRUE -5.887394 -5.887394 331.9114 <list[1]>
#>        8  170   TRUE -5.946115 -5.946115 351.9852 <list[1]>
#>       11  707   TRUE -5.805575 -5.805575 305.8360 <list[1]>
#>      ---  ---    ---       ---       ---      ---       ---
#>      158  185  FALSE -5.909842 -5.909842 339.4465 <list[1]>
#>      160  183   TRUE -5.833310 -5.833310 314.4371 <list[1]>
#>      161  211  FALSE -6.173711 -6.173711 428.0021 <list[1]>

# Score the predictions
predictions$score()
#> surv.cindex 
#>   0.5970395