Survival Task Generator for Package 'simsurv'
Source:R/TaskGeneratorSimsurv.R
      mlr_task_generators_simsurv.RdA 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():
Parameters
| Id | Type | Default | Levels | Range | 
| dist | character | weibull | weibull, exponential, gompertz | - | 
| lambdas | numeric | - | \([0, \infty)\) | |
| gammas | numeric | - | \([0, \infty)\) | |
| maxt | numeric | - | \([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
- as.data.table(mlr_task_generators)for a table of available TaskGenerators in the running session
Other TaskGenerator:
mlr_task_generators_coxed,
mlr_task_generators_simdens
Super class
mlr3::TaskGenerator -> TaskGeneratorSimsurv
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:  1.379427      1 151.8680         1 80.52075
#> 2:  5.000000      0 185.9242         1 82.85124
#> 3:  5.000000      0 166.2240         1 89.84010
#> 4:  5.000000      0 150.3844         1 81.55950
#> 5:  4.250381      1 163.7347         1 90.79093
#> 6:  5.000000      0 172.9649         1 85.11452
  # 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.5918305      1 157.2615         0 60.97819
#> 2:  3.2588734      1 157.9940         1 78.06570
#> 3: 33.9640224      1 162.4152         0 67.66418
#> 4:  0.4700053      1 172.1267         0 83.22141
#> 5: 40.0000000      0 170.7479         1 82.32868
#> 6:  5.6373356      1 158.6357         0 84.88671