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)\) |
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
if (requireNamespace("simsurv", quietly = TRUE)) {
# generate 20 samples with Weibull survival distribution
gen = tgen("simsurv")
task = gen$generate(20)
head(task)
# 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: 17.171312 1 167.6429 1 77.23948
#> 2: 4.433043 1 188.4940 0 82.81777
#> 3: 15.311016 1 180.4851 1 98.84231
#> 4: 17.578863 1 169.5473 0 61.78893
#> 5: 40.000000 0 159.8246 1 65.27973
#> 6: 6.553888 1 186.5408 1 88.89694