Survival Task Generator for Package 'simsurv'
Source:R/TaskGeneratorSimsurv.R
mlr_task_generators_simsurv.Rd
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 ratio0.5
.height
: Normally distributed with hazard ratio1
.weight
: normally distributed with hazard ratio1
.
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: 4.722029 1 160.4491 0 91.39158
#> 2: 2.748901 1 159.5854 0 81.70784
#> 3: 1.880703 1 175.1759 0 79.92841
#> 4: 5.000000 0 173.7549 1 70.10283
#> 5: 2.758909 1 173.5845 0 77.85363
#> 6: 5.000000 0 176.7559 1 73.66173
# 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: 28.910379 1 162.6955 1 76.32827
#> 2: 6.810159 1 168.9355 0 71.42271
#> 3: 20.444209 1 168.6686 1 70.20593
#> 4: 4.324903 1 171.0205 0 74.50941
#> 5: 7.866362 1 204.4362 0 83.79403
#> 6: 4.059363 1 165.1062 0 78.03904