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: 5.0000000 0 172.1168 1 75.25959
#> 2: 4.3382880 1 166.1004 0 63.62824
#> 3: 5.0000000 0 183.6185 1 69.24727
#> 4: 5.0000000 0 159.2613 1 55.11225
#> 5: 4.9182157 1 166.8404 1 71.29397
#> 6: 0.7727374 1 171.6880 0 70.25863
# 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.2007089 1 169.6693 1 105.96437
#> 2: 9.1542798 1 171.7075 0 79.97792
#> 3: 8.2892220 1 157.0461 1 82.24655
#> 4: 0.8816916 1 158.6124 0 62.84515
#> 5: 3.8204925 1 164.6303 0 80.63864
#> 6: 10.0142678 1 169.8157 0 90.74922