Load the packages we need.
Create a survival model, and generate data.
sm <- SurvivalModel(baseHazard = 1/5, # default 1/5 inverse years
accrual = 5, # default 5 years
followUp = 1, # default 1 years
units = 12, unitName = "months")
R <- rand(sm, 200)
summary(R)
## LFU Event
## Min. : 0.00 Mode :logical
## 1st Qu.:14.75 FALSE:101
## Median :28.00 TRUE :99
## Mean :29.25
## 3rd Qu.:41.00
## Max. :70.00
Fit a Kaplan-Meier curve.
Now create several cancer models and generate data.
for (ignore in 1:5) {
for (jgnore in 1:4) {
cm <- CancerModel("survtester", nPossible=20, nPattern=2,
SURV = function(n) rnorm(n, 0, 2), # old default; too large
survivalModel = sm)
S <- rand(cm, 200)
model <- survfit(Surv(LFU, Event) ~ CancerSubType, S)
print(model)
plot(model)
}
}
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 90 9 NA NA NA
## CancerSubType=2 110 101 8 6 9
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 98 5 NA NA NA
## CancerSubType=2 102 0 NA NA NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 101 101 0 NA NA
## CancerSubType=2 99 94 7 5 10
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 103 95 6 5 11
## CancerSubType=2 97 97 0 0 0
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 94 81 13 11 19
## CancerSubType=2 106 88 12 10 17
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 94 94 1 1 2
## CancerSubType=2 106 0 NA NA NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 101 48 43 30 NA
## CancerSubType=2 99 72 22 18 30
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 89 2 NA NA NA
## CancerSubType=2 111 90 15 11 19
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 100 100 0 0 0
## CancerSubType=2 100 0 NA NA NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 101 12 NA NA NA
## CancerSubType=2 99 99 0 0 0
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 97 0 NA NA NA
## CancerSubType=2 103 53 34 27 53
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 102 1 NA NA NA
## CancerSubType=2 98 93 5 4 6
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 103 98 7 5 9
## CancerSubType=2 97 3 NA NA NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 113 37 NA 64 NA
## CancerSubType=2 87 87 1 0 2
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 117 1 NA NA NA
## CancerSubType=2 83 83 1 1 2
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 103 102 2 2 3
## CancerSubType=2 97 12 NA NA NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 105 18 NA NA NA
## CancerSubType=2 95 27 NA 57 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 93 4 NA NA NA
## CancerSubType=2 107 89 15 12 17
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 88 72 11 7 19
## CancerSubType=2 112 111 3 2 4
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 108 108 0 0 0
## CancerSubType=2 92 92 0 NA NA
Now create several cancer models and generate data.
for (ignore in 1:5) {
for (jgnore in 1:4) {
cm <- CancerModel("survtester", nPossible=20, nPattern=2,
SURV = function(n) rnorm(n, 0, 0.3),
survivalModel = sm)
S <- rand(cm, 200)
model <- survfit(Surv(LFU, Event) ~ CancerSubType, S)
print(model)
plot(model)
}
}
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 92 40 45 41 NA
## CancerSubType=2 108 62 34 27 42
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 89 29 NA 59 NA
## CancerSubType=2 111 46 51 39 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 94 35 NA 47 NA
## CancerSubType=2 106 39 62 52 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 111 89 17 13 22
## CancerSubType=2 89 63 25 15 33
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 102 22 NA NA NA
## CancerSubType=2 98 78 15 11 22
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 78 54 15 11 22
## CancerSubType=2 122 70 28 21 44
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 98 34 NA 41 NA
## CancerSubType=2 102 28 NA 57 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 95 43 51 31 NA
## CancerSubType=2 105 63 28 22 45
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 98 19 NA NA NA
## CancerSubType=2 102 29 NA 55 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 97 56 32 27 46
## CancerSubType=2 103 37 56 47 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 94 60 26 18 36
## CancerSubType=2 106 52 43 23 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 100 5 NA NA NA
## CancerSubType=2 100 41 54 41 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 106 40 61 48 NA
## CancerSubType=2 94 31 68 56 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 96 46 34 27 NA
## CancerSubType=2 104 28 NA 56 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 111 87 16 12 21
## CancerSubType=2 89 41 40 36 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 96 55 26 20 55
## CancerSubType=2 104 53 42 27 56
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 107 65 36 24 46
## CancerSubType=2 93 24 63 57 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 98 66 19 17 28
## CancerSubType=2 102 51 35 30 49
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 95 73 23 18 29
## CancerSubType=2 105 74 21 17 26
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 105 94 11 9 15
## CancerSubType=2 95 30 NA 56 NA
for (nPos in c(5, 10, 15)) {
for (jgnore in 1:4) {
cm <- CancerModel("survtester", nPossible=nPos, nPattern=2,
SURV = function(n) rnorm(n, 0, 0.3),
survivalModel = sm)
S <- rand(cm, 200)
model <- survfit(Surv(LFU, Event) ~ CancerSubType, S)
print(model)
plot(model)
}
}
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 90 76 12 11 15
## CancerSubType=2 110 97 12 8 19
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 101 18 NA NA NA
## CancerSubType=2 99 19 NA NA NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 92 50 34 24 51
## CancerSubType=2 108 56 38 28 50
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 95 48 40 29 51
## CancerSubType=2 105 48 45 40 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 99 14 NA NA NA
## CancerSubType=2 101 19 NA 61 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 91 72 15 12 23
## CancerSubType=2 109 75 21 18 35
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 96 27 NA 50 NA
## CancerSubType=2 104 40 47 38 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 99 47 39 30 NA
## CancerSubType=2 101 53 33 30 61
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 100 35 NA 45 NA
## CancerSubType=2 100 19 NA NA NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 100 48 43 26 NA
## CancerSubType=2 100 53 31 23 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 97 27 NA 62 NA
## CancerSubType=2 103 44 47 36 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 98 33 NA 53 NA
## CancerSubType=2 102 24 NA 62 NA
## R version 4.4.1 (2024-06-14)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.1 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=C
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## time zone: Etc/UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] survival_3.7-0 Umpire_2.0.10 rmarkdown_2.28
##
## loaded via a namespace (and not attached):
## [1] sass_0.4.9 utf8_1.2.4 generics_0.1.3 tidyr_1.3.1
## [5] rstatix_0.7.2 lattice_0.22-6 digest_0.6.37 magrittr_2.0.3
## [9] evaluate_1.0.0 grid_4.4.1 mvtnorm_1.3-1 fastmap_1.2.0
## [13] Matrix_1.7-0 jsonlite_1.8.9 backports_1.5.0 Formula_1.2-5
## [17] mclust_6.1.1 purrr_1.0.2 fansi_1.0.6 mc2d_0.2.1
## [21] BimodalIndex_1.1.9 scales_1.3.0 jquerylib_0.1.4 abind_1.4-8
## [25] cli_3.6.3 rlang_1.1.4 splines_4.4.1 munsell_0.5.1
## [29] cachem_1.1.0 yaml_2.3.10 tools_4.4.1 ggsignif_0.6.4
## [33] dplyr_1.1.4 colorspace_2.1-1 ggplot2_3.5.1 ggpubr_0.6.0
## [37] broom_1.0.7 buildtools_1.0.0 vctrs_0.6.5 R6_2.5.1
## [41] lifecycle_1.0.4 car_3.1-3 oompaBase_3.2.9 cluster_2.1.6
## [45] pkgconfig_2.0.3 pillar_1.9.0 bslib_0.8.0 gtable_0.3.5
## [49] glue_1.8.0 highr_0.11 xfun_0.48 tibble_3.2.1
## [53] tidyselect_1.2.1 sys_3.4.3 knitr_1.48 htmltools_0.5.8.1
## [57] carData_3.0-5 maketools_1.3.1 compiler_4.4.1