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.00 FALSE:114
## Median :26.50 TRUE :86
## Mean :29.05
## 3rd Qu.:40.25
## Max. :71.00
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 89 65 21 16 28
## CancerSubType=2 111 28 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 91 0 NA NA NA
## CancerSubType=2 109 109 1 1 2
Two group survival curves (original).
## 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 21 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 104 103 2 1 3
## CancerSubType=2 96 7 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 101 62 25 22 41
## CancerSubType=2 99 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 95 22 NA 60 NA
## CancerSubType=2 105 23 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 0 NA NA NA
## CancerSubType=2 94 91 5 4 6
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 0 0
## CancerSubType=2 95 95 6 4 8
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 97 97 0 0 1
## CancerSubType=2 103 64 26 22 34
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 110 110 0 NA NA
## CancerSubType=2 90 90 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 102 102 0 0 0
## 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 106 65 40 29 47
## CancerSubType=2 94 26 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 92 63 22 17 28
## CancerSubType=2 108 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 97 97 0 NA NA
## CancerSubType=2 103 103 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 103 34 NA 50 NA
## CancerSubType=2 97 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 107 107 2 1 3
## CancerSubType=2 93 88 6 4 8
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 81 14 NA NA NA
## CancerSubType=2 119 9 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 99 99 0 NA NA
## CancerSubType=2 101 101 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 112 63 34 25 44
## CancerSubType=2 88 75 15 12 22
Two group survival curves (original).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 96 0 NA NA NA
## CancerSubType=2 104 0 NA NA NA
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 98 72 19 15 26
## CancerSubType=2 102 68 26 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 93 55 27 20 42
## CancerSubType=2 107 27 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 101 50 45 32 NA
## CancerSubType=2 99 38 56 45 NA
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 95 34 59 38 NA
## CancerSubType=2 105 39 55 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 85 13 10 18
## CancerSubType=2 97 72 19 14 24
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 90 51 29 20 47
## CancerSubType=2 110 57 37 32 49
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 98 35 58 49 NA
## CancerSubType=2 102 30 NA 49 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 48 49 36 NA
## CancerSubType=2 99 50 32 27 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 83 10 8 12
## CancerSubType=2 107 35 NA 51 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 24 NA NA NA
## CancerSubType=2 103 29 NA 54 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 50 45 38 59
## CancerSubType=2 96 55 33 21 43
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 98 81 10 8 17
## CancerSubType=2 102 73 21 15 30
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 87 75 12 10 19
## CancerSubType=2 113 48 50 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 104 54 41 27 NA
## CancerSubType=2 96 65 27 21 36
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 108 93 9 8 14
## CancerSubType=2 92 45 48 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 94 46 37 31 51
## CancerSubType=2 106 37 56 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 111 71 24 21 31
## CancerSubType=2 89 44 36 24 NA
Two group survival curves (improved).
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 100 49 38 30 NA
## CancerSubType=2 100 35 68 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 100 53 32 28 52
## CancerSubType=2 100 27 70 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 100 45 52 34 NA
## CancerSubType=2 100 43 54 37 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 102 39 69 44 NA
## CancerSubType=2 98 41 53 36 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 104 67 28 19 37
## CancerSubType=2 96 66 25 17 33
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 105 19 NA 70 NA
## CancerSubType=2 95 25 NA 56 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 107 78 20 15 26
## CancerSubType=2 93 60 23 20 30
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 96 41 53 44 NA
## CancerSubType=2 104 57 39 33 50
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 98 43 45 40 NA
## CancerSubType=2 102 53 37 33 55
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 105 20 NA NA NA
## CancerSubType=2 95 39 68 40 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 97 11 NA NA NA
## CancerSubType=2 103 18 NA NA NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 97 54 36 22 54
## CancerSubType=2 103 78 15 10 22
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 107 92 11 8 18
## CancerSubType=2 93 49 30 25 NA
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 95 49 33 28 62
## CancerSubType=2 105 89 13 11 18
## Call: survfit(formula = Surv(LFU, Event) ~ CancerSubType, data = S)
##
## n events median 0.95LCL 0.95UCL
## CancerSubType=1 95 50 35 31 56
## CancerSubType=2 105 66 27 21 38
## R version 4.6.0 (2026-04-24)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.4 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=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-6 Umpire_2.0.11 rmarkdown_2.31
##
## loaded via a namespace (and not attached):
## [1] sass_0.4.10 generics_0.1.4 tidyr_1.3.2
## [4] rstatix_0.7.3 lattice_0.22-9 digest_0.6.39
## [7] magrittr_2.0.5 evaluate_1.0.5 grid_4.6.0
## [10] RColorBrewer_1.1-3 mvtnorm_1.4-0 fastmap_1.2.0
## [13] Matrix_1.7-5 jsonlite_2.0.0 backports_1.5.1
## [16] Formula_1.2-5 mclust_6.1.2 purrr_1.2.2
## [19] mc2d_0.2.1 BimodalIndex_1.1.11 scales_1.4.0
## [22] jquerylib_0.1.4 abind_1.4-8 cli_3.6.6
## [25] rlang_1.2.0 splines_4.6.0 cachem_1.1.0
## [28] yaml_2.3.12 tools_4.6.0 ggsignif_0.6.4
## [31] dplyr_1.2.1 ggplot2_4.0.3 ggpubr_0.6.3
## [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.11 cluster_2.1.8.2 pkgconfig_2.0.3
## [43] pillar_1.11.1 bslib_0.11.0 gtable_0.3.6
## [46] glue_1.8.1 xfun_0.57 tibble_3.3.1
## [49] tidyselect_1.2.1 sys_3.4.3 knitr_1.51
## [52] farver_2.1.2 htmltools_0.5.9 carData_3.0-6
## [55] maketools_1.3.2 compiler_4.6.0 S7_0.2.2