Skip to contents

A mlr3::TaskGenerator calling simsurv::simsurv() from package simsurv.

This generator currently only exposes a small subset of the flexibility of simsurv, and just creates a small dataset with the following numerical covariates:

  • treatment: Bernoulli distributed with hazard ratio 0.5.

  • height: Normally distributed with hazard ratio 1.

  • weight: normally distributed with hazard ratio 1.

See simsurv::simsurv() for an explanation of the hyperparameters. Initial values for hyperparameters are lambdas = 0.1, gammas = 1.5 and maxt = 5. The last one, by default generates samples which are administratively censored at \(\tau = 5\), so increase this value if you want to change this.

Dictionary

This TaskGenerator can be instantiated via the dictionary mlr_task_generators or with the associated sugar function tgen():

mlr_task_generators$get("simsurv")
tgen("simsurv")

Parameters

IdTypeDefaultLevelsRange
distcharacterweibullweibull, exponential, gompertz-
lambdasnumeric-\([0, \infty)\)
gammasnumeric-\([0, \infty)\)
maxtnumeric-\([0, \infty)\)

References

Brilleman, L. S, Wolfe, Rory, Moreno-Betancur, Margarita, Crowther, J. M (2021). “Simulating Survival Data Using the simsurv R Package.” Journal of Statistical Software, 97(3), 1–27. doi:10.18637/JSS.V097.I03 .

See also

Other TaskGenerator: mlr_task_generators_coxed, mlr_task_generators_simdens

Super class

mlr3::TaskGenerator -> TaskGeneratorSimsurv

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method help()

Opens the corresponding help page referenced by field $man.

Usage

TaskGeneratorSimsurv$help()


Method clone()

The objects of this class are cloneable with this method.

Usage

TaskGeneratorSimsurv$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

  # generate 20 samples with Weibull survival distribution
  gen = tgen("simsurv")
  task = gen$generate(20)
  head(task)
#>    eventtime status   height treatment   weight
#>        <num>  <int>    <num>     <int>    <num>
#> 1:  3.614056      1 164.5435         0 96.28355
#> 2:  3.639137      1 172.0963         1 77.42444
#> 3:  3.649547      1 165.8563         0 86.11930
#> 4:  5.000000      0 182.1474         1 90.72207
#> 5:  5.000000      0 161.6110         0 75.82238
#> 6:  5.000000      0 157.5449         0 73.86433

  # generate 100 samples with exponential survival distribution and tau = 40
  gen = tgen("simsurv", dist = "exponential", gammas = NULL, maxt = 40)
  task = gen$generate(100)
  head(task)
#>     eventtime status   height treatment   weight
#>         <num>  <int>    <num>     <int>    <num>
#> 1:  4.4003352      1 173.3892         1 83.08383
#> 2:  4.7709793      1 182.7733         0 60.16601
#> 3:  1.0152890      1 167.4973         0 75.53396
#> 4:  0.9686478      1 174.7111         0 71.32231
#> 5:  5.0880338      1 160.6400         0 90.43653
#> 6: 23.7286477      1 174.7952         1 74.18802