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.0 Mode :logical
## 1st Qu.:13.0 FALSE:93
## Median :23.0 TRUE :107
## Mean :27.3
## 3rd Qu.:40.0
## Max. :70.0
Fit a Kaplan-Meier curve.
Base Kaplan-Meier survival 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 87 0 NA NA NA
## CancerSubType=2 113 0 NA NA NA
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 105 55 37 29 51
## CancerSubType=2 95 95 2 1 4
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 102 102 2 1 2
## CancerSubType=2 98 66 29 25 33
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 92 10 NA NA NA
## CancerSubType=2 108 108 0 0 0
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 109 16 NA NA NA
## CancerSubType=2 91 85 10 7 13
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 102 37 NA 39 NA
## CancerSubType=2 98 0 NA NA NA
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 103 103 1 0 1
## CancerSubType=2 97 97 1 0 1
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 105 105 0 NA NA
## CancerSubType=2 95 58 30 22 47
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 100 11 NA NA NA
## CancerSubType=2 100 17 NA 64 NA
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 94 0 NA NA NA
## CancerSubType=2 106 106 0 NA NA
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 107 107 2 1 3
## CancerSubType=2 93 4 NA NA NA
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 106 106 0 0 1
## CancerSubType=2 94 37 52 37 NA
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 102 102 2 1 2
## CancerSubType=2 98 98 0 NA NA
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 94 71 17 15 21
## CancerSubType=2 106 1 NA NA NA
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 96 88 7 6 10
## CancerSubType=2 104 2 NA NA NA
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 107 107 0 NA NA
## CancerSubType=2 93 93 0 0 0
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 95 0 NA NA NA
## CancerSubType=2 105 51 34 27 NA
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 101 101 0 0 0
## CancerSubType=2 99 8 NA NA NA
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 107 105 5 3 7
## CancerSubType=2 93 93 0 NA NA
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 103 0 NA NA NA
## CancerSubType=2 97 97 1 0 1
Two group survival curves (original).
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 96 15 NA NA NA
## CancerSubType=2 104 26 NA NA NA
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 104 41 NA 37 NA
## CancerSubType=2 96 35 54 42 NA
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 103 92 12 8 15
## CancerSubType=2 97 65 22 14 31
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 104 61 27 21 41
## CancerSubType=2 96 82 12 10 19
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 102 39 NA 40 NA
## CancerSubType=2 98 63 27 20 36
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 90 65 28 23 31
## CancerSubType=2 110 59 32 27 46
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 111 44 64 41 NA
## CancerSubType=2 89 47 36 26 48
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 98 47 40 26 NA
## CancerSubType=2 102 41 53 43 NA
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 93 51 35 29 50
## CancerSubType=2 107 22 NA NA NA
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 98 54 36 26 48
## CancerSubType=2 102 33 NA 50 NA
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 92 31 NA 44 NA
## CancerSubType=2 108 32 NA 59 NA
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 103 60 33 22 42
## CancerSubType=2 97 37 68 39 NA
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 104 47 42 30 NA
## CancerSubType=2 96 68 23 19 33
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 106 47 42 34 NA
## CancerSubType=2 94 41 68 30 NA
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 118 93 13 10 20
## CancerSubType=2 82 76 8 6 13
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 91 21 NA NA NA
## CancerSubType=2 109 17 NA NA NA
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 97 65 22 19 33
## CancerSubType=2 103 65 27 17 41
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 103 72 23 16 32
## CancerSubType=2 97 38 51 38 NA
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 101 87 9 7 12
## CancerSubType=2 99 72 18 15 25
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 93 41 48 29 NA
## CancerSubType=2 107 22 NA NA NA
Two group survival curves (improved).
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 99 64 21 16 30
## CancerSubType=2 101 73 21 17 27
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 115 58 42 32 49
## CancerSubType=2 85 56 25 21 36
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 108 50 44 28 NA
## CancerSubType=2 92 41 55 41 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 95 62 24 20 36
## CancerSubType=2 105 74 24 17 32
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 100 57 28 22 46
## CancerSubType=2 100 71 24 21 30
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 84 76 11 8 15
## CancerSubType=2 116 30 NA 65 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 87 17 NA NA NA
## CancerSubType=2 113 38 NA 56 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 110 55 41 30 59
## CancerSubType=2 90 45 45 26 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 98 23 NA NA NA
## CancerSubType=2 102 47 43 36 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 102 43 NA 27 NA
## CancerSubType=2 98 31 NA 57 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 107 31 NA 52 NA
## CancerSubType=2 93 47 35 25 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 105 23 NA NA NA
## CancerSubType=2 95 67 21 12 27
## R version 4.6.1 (2026-06-24)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 26.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.32.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=en_US.UTF-8
## [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.8-12 Umpire_2.0.12 rmarkdown_2.32
##
## loaded via a namespace (and not attached):
## [1] sass_0.4.10 generics_0.1.4 tidyr_1.3.2
## [4] rstatix_1.1.0 lattice_0.23-1 digest_0.6.39
## [7] magrittr_2.0.5 evaluate_1.0.5 grid_4.6.1
## [10] RColorBrewer_1.1-3 mvtnorm_1.4-2 fastmap_1.2.0
## [13] Matrix_1.7-6 jsonlite_2.0.0 backports_1.5.1
## [16] Formula_1.2-6 mclust_6.1.3 purrr_1.2.2
## [19] mc2d_0.2.2 BimodalIndex_1.1.13 scales_1.4.0
## [22] jquerylib_0.1.4 abind_1.4-8 cli_3.6.6
## [25] rlang_1.3.0 splines_4.6.1 cachem_1.1.0
## [28] yaml_2.3.12 tools_4.6.1 ggsignif_0.6.4
## [31] dplyr_1.2.1 ggplot2_4.0.3 ggpubr_1.0.0
## [34] broom_1.0.13 buildtools_1.0.0 vctrs_0.7.3
## [37] R6_2.6.1 lifecycle_1.0.5 car_3.1-5
## [40] oompaBase_3.2.12 cluster_2.1.8.3 pkgconfig_2.0.3
## [43] pillar_1.11.1 bslib_0.12.0 gtable_0.3.6
## [46] glue_1.8.1 xfun_0.61 tibble_3.3.1
## [49] tidyselect_1.2.1 sys_3.4.3 knitr_1.52
## [52] farver_2.1.2 htmltools_0.5.9 carData_3.0-6
## [55] maketools_1.3.2 compiler_4.6.1 S7_0.2.2