Umpire 2.0: Simulating Associated Survival

Kevin R. Coombes and Caitlin E. Coombes

Load the packages we need.

library(Umpire)
library(survival)

Base Survival

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.

baseModel <- survfit(Surv(LFU, Event) ~ 1, R)
plot(baseModel)

Base Kaplan-Meier survival curve.

Default method to generate beta coefficients.

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

Two group survival curves (original).

## 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

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      NA      NA
## CancerSubType=2  99     94      7       5      10

Two group survival curves (original).

## 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

Two group survival curves (original).

## 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

Two group survival curves (original).

## 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

Two group survival curves (original).

## 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

Two group survival curves (original).

## 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

Two group survival curves (original).

## 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

Two group survival curves (original).

## 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

Two group survival curves (original).

## 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

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     93      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 103     98      7       5       9
## CancerSubType=2  97      3     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 113     37     NA      64      NA
## CancerSubType=2  87     87      1       0       2

Two group survival curves (original).

## 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

Two group survival curves (original).

## 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

Two group survival curves (original).

## 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

Two group survival curves (original).

## 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

Two group survival curves (original).

## 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

Two group survival curves (original).

## 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

Two group survival curves (original).

Better method to generate beta coefficients.

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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

## 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

Two group survival curves (improved).

Fewer possible hits

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

Appendix

sessionInfo()
## R version 4.0.3 (2020-10-10)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19041)
## 
## Matrix products: default
## 
## locale:
## [1] LC_COLLATE=C                          
## [2] LC_CTYPE=English_United States.1252   
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.1252    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] survival_3.2-7 Umpire_2.0.10 
## 
## loaded via a namespace (and not attached):
##  [1] mclust_5.4.6       lattice_0.20-41    mvtnorm_1.1-1      digest_0.6.25     
##  [5] grid_4.0.3         mc2d_0.1-18        magrittr_1.5       evaluate_0.14     
##  [9] oompaBase_3.2.9    highr_0.8          rlang_0.4.8        stringi_1.5.3     
## [13] Matrix_1.2-18      rmarkdown_2.4      splines_4.0.3      tools_4.0.3       
## [17] stringr_1.4.0      xfun_0.18          yaml_2.2.1         compiler_4.0.3    
## [21] cluster_2.1.0      BimodalIndex_1.1.9 htmltools_0.5.0    knitr_1.30