# wintime_vignette

# wintime Package Guide

This vignette demonstrates the use of the three available functions contained in the wintime package: `wintime`, `markov`, and `km`. The `wintime` function is the main function of the package that implements the methods described in “Use of win time for ordered composite endpoints in clinical trials,” (Troendle et al. 2024), https://pubmed.ncbi.nlm.nih.gov/38417455/. This function accepts data with any number of endpoints and runs these methods on observed and resampled data. The `markov` function fits an extended Markov model to estimate the state probabilities for each arm. The `km` function performs the same estimation using Kaplan-Meier models.

## Installation

To use these functions, you need to have the `wintime` package installed. You can install it from CRAN using the `install.packages(wintime)` command.

## Load Required Packages

Load the `wintime` package along with the `survival` package.

    library(wintime)
    library(survival)

## Example Data

In this section, we will create example data to demonstrate the use of the package functions. The data includes event times, event indicators, treatment arm indicators, and optional covariates. We will consider a dataset with 3 endpoints ordered into a composite. In this dataset, the event time vectors are titled `TIME_1`, `TIME_2`, and `TIME_3`. These must be organized into a matrix with rows representing events and columns representing participants. It is critical that event rows are in INCREASING order of severity. The event indicator vectors, titled `DELTA_1`, `DELTA_2`, and `DELTA_3`, will be organized the same way as the event times. The treatment arm indicator vector, titled `trt`, will be entered as a vector containing 1’s and 0’s (control = 0, treatment = 1). Covariates are optional, but if they are entered into the `wintime` function, they must also be entered as a matrix. The three covariates in this dataset, titled `cov1`, `cov2`, and `cov3`, will be organized into a matrix with rows representing participants and columns representing covariate values.

    # Event time vectors
    TIME_1 <- c(256,44,29,186,29,80,11,380,102,33)
    TIME_2 <- c(128,44,95,186,69,66,153,380,117,33)
    TIME_3 <- c(435,44,95,186,69,270,1063,380,117,33)

    # Event time matrix
    Time <- rbind(TIME_1, TIME_2, TIME_3)

    # Event indicator vectors
    DELTA_1 <- c(1,0,1,0,1,1,1,0,1,0)
    DELTA_2 <- c(1,0,0,0,0,1,1,0,0,0)
    DELTA_3 <- c(0,0,0,0,0,0,0,0,0,0)

    # Event indicator matrix
    Delta <- rbind(DELTA_1, DELTA_2, DELTA_3)

    # Treatment arm indicator vector
    trt <- c(1,1,1,1,1,0,0,0,0,0)

    # Covariate vectors
    cov1 <- c(66,67,54,68,77,65,55,66,77,54)
    cov2 <- c(3,6,4,2,3,5,8,5,3,5)
    cov3 <- c(34.6,543.6,45.8,54.7,44.3,55.6,65.9,54.7,77.9,31.2)

    # Covariate matrix
    cov <- cbind(cov1, cov2, cov3)

    cat("Time =", "\n")

    ## Time =

    print(Time)

    ##        [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
    ## TIME_1  256   44   29  186   29   80   11  380  102    33
    ## TIME_2  128   44   95  186   69   66  153  380  117    33
    ## TIME_3  435   44   95  186   69  270 1063  380  117    33

    cat("Delta =", "\n")

    ## Delta =

    print(Delta)

    ##         [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
    ## DELTA_1    1    0    1    0    1    1    1    0    1     0
    ## DELTA_2    1    0    0    0    0    1    1    0    0     0
    ## DELTA_3    0    0    0    0    0    0    0    0    0     0

    cat("trt", "\n")

    ## trt

    print(trt)

    ##  [1] 1 1 1 1 1 0 0 0 0 0

    cat("cov =", "\n")

    ## cov =

    print(cov)

    ##       cov1 cov2  cov3
    ##  [1,]   66    3  34.6
    ##  [2,]   67    6 543.6
    ##  [3,]   54    4  45.8
    ##  [4,]   68    2  54.7
    ##  [5,]   77    3  44.3
    ##  [6,]   65    5  55.6
    ##  [7,]   55    8  65.9
    ##  [8,]   66    5  54.7
    ##  [9,]   77    3  77.9
    ## [10,]   54    5  31.2

## wintime Function

The required arguments for the `wintime` function are the desired win time method, a matrix of event times, a matrix of event indicators, and a vector of treatment arm indicators. The win time method is entered as a string value indicating which method will be run. Methods include: `wtr`, `rwtr`, `pwt`, `ewtr`, `ewt`, `max`, `rmt`, ‘ewtp’, ‘rewtp’, ‘ewtpr’, ‘rewtpr’, and ‘rpwt’. This section will demonstrate the use of each method with default settings. Each of these function calls will return a list with nine elements: the observed treatment effect, a vector of resampled treatment effects (this will be empty with no resampling), a message describing which method was used, the variance, the p-value, the number of wins for treatment (pairwise methods only), the number of losses for treatment (pairwise methods only), a vector of length ‘m’ with the components of the treatment effect, and a vector of length ‘m’ with the variance of the components.

### Win time ratio (wtr)

    # Run wtr
    result <- wintime("wtr", Time, Delta, trt)
    print(result)

    ## $trt_effect
    ## [1] 1
    ##
    ## $resample_data
    ## numeric(0)
    ##
    ## $message
    ## [1] "Resampling of  wtr  done on  0  bootstraps."
    ##
    ## $variance
    ## [1] NA
    ##
    ## $p
    ## [1] NA
    ##
    ## $wins
    ## [1] 9
    ##
    ## $losses
    ## [1] 9
    ##
    ## $components
    ## [1] NA NA NA
    ##
    ## $components_var
    ## [1] NA NA NA
    ##
    ## $max_time
    ## [1] NA NA NA

### Restricted win time ratio (rwtr)

    # Run rwtr
    result <- wintime("rwtr", Time, Delta, trt)
    print(result)

    ## $trt_effect
    ## [1] 1
    ##
    ## $resample_data
    ## numeric(0)
    ##
    ## $message
    ## [1] "Resampling of  rwtr  done on  0  bootstraps."
    ##
    ## $variance
    ## [1] NA
    ##
    ## $p
    ## [1] NA
    ##
    ## $wins
    ## [1] 9
    ##
    ## $losses
    ## [1] 9
    ##
    ## $components
    ## [1] NA NA NA
    ##
    ## $components_var
    ## [1] NA NA NA
    ##
    ## $max_time
    ## [1] NA NA NA

### Pairwise win time (pwt)

    # Run pwt
    result <- wintime("pwt", Time, Delta, trt)
    print(result)

    ## $trt_effect
    ## [1] 1.36
    ##
    ## $resample_data
    ## numeric(0)
    ##
    ## $message
    ## [1] "Resampling of  pwt  done on  0  bootstraps."
    ##
    ## $variance
    ## [1] NA
    ##
    ## $p
    ## [1] NA
    ##
    ## $wins
    ## [1] NA
    ##
    ## $losses
    ## [1] NA
    ##
    ## $components
    ## [1]  2.56 -1.20  0.00
    ##
    ## $components_var
    ## [1] NA NA NA
    ##
    ## $max_time
    ## [1] NA NA NA

### Expected win time against reference (ewtr)

The ewtr method accepts a matrix of covariates as an optional argument. If you wish to enter covariates, pass it as the value of `cov`.

    # Run ewtr with covariates
    result <- wintime("ewtr", Time, Delta, trt, cov = cov)
    print(result)

    ## $trt_effect
    ##       trt
    ## -151.5074
    ##
    ## $resample_data
    ## [1] NA
    ##
    ## $message
    ## NULL
    ##
    ## $variance
    ## [1] 14851.69
    ##
    ## $p
    ##       trt
    ## 0.1068945
    ##
    ## $wins
    ## [1] NA
    ##
    ## $losses
    ## [1] NA
    ##
    ## $components
    ## [1] -53.22352 -98.28383   0.00000
    ##
    ## $components_var
    ## [1]   949.9295 11528.9055     0.0000
    ##
    ## $max_time
    ## [1] NA NA NA

### Expected win time (ewt)

    # Run ewt
    result <- wintime("ewt", Time, Delta, trt)
    print(result)

    ## $trt_effect
    ## [1] 1.033333
    ##
    ## $resample_data
    ## numeric(0)
    ##
    ## $message
    ## [1] "Resampling of  ewt  done on  0  permutations."
    ##
    ## $variance
    ## [1] NA
    ##
    ## $p
    ## [1] 1
    ##
    ## $wins
    ## [1] NA
    ##
    ## $losses
    ## [1] NA
    ##
    ## $components
    ## [1] -6.216667  7.250000  0.000000
    ##
    ## $components_var
    ## [1] NA NA NA
    ##
    ## $max_time
    ## [1] 95

### EWTR-composite max test (max)

    # Run max
    result <- wintime("max", Time, Delta, trt, cov = cov)
    print(result)

    ## $trt_effect
    ## [1] -1.243214
    ##
    ## $resample_data
    ## numeric(0)
    ##
    ## $message
    ## [1] "Resampling of  max  done on  0  bootstraps."
    ##
    ## $variance
    ## [1] NA
    ##
    ## $p
    ## [1] 1
    ##
    ## $wins
    ## [1] NA
    ##
    ## $losses
    ## [1] NA
    ##
    ## $components
    ## [1] NA NA NA
    ##
    ## $components_var
    ## [1] NA NA NA
    ##
    ## $max_time
    ## [1] NA NA NA

### Restricted mean survival in favor of treatment (rmt)

For this method, the `time_restriction` argument must be passed. This is the cutoff time for the rmt method.

    # Run rmt
    result <- wintime("rmt", Time, Delta, trt, time_restriction = round(1.5*365.25))
    print(result)

    ## $trt_effect
    ## [1] 1.033333
    ##
    ## $resample_data
    ## numeric(0)
    ##
    ## $message
    ## [1] "Resampling of  rmt  done on  0  permutations."
    ##
    ## $variance
    ## [1] NA
    ##
    ## $p
    ## [1] 1
    ##
    ## $wins
    ## [1] NA
    ##
    ## $losses
    ## [1] NA
    ##
    ## $components
    ## [1] -6.216667  7.250000  0.000000
    ##
    ## $components_var
    ## [1] NA NA NA
    ##
    ## $max_time
    ## [1] 95

## Resampling

In this section, we will demonstrate the use of resampling with a few of the win time methods. To run a win time method with resampling, just pass the `resample_num` argument as an integer value that tells the `wintime` function how many times you wish to resample. Each method is either resampled with bootstraps or permutations by default. The third element of the returned list will indicate which resampling technique was used. Resampling involves random number generation, so we can pass the optional `seed` argument for replicability.

### ewt with 10 Resamples

    # Run ewt with 10 resamples
    result <- wintime("ewt", Time, Delta, trt, resample_num = 10, seed = 123)
    print(result)

    ## $trt_effect
    ## [1] 1.033333
    ##
    ## $resample_data
    ##  [1]  24.200000  26.950000  12.650000   8.680000  -8.720000  12.320000
    ##  [7] -73.987500 -62.600000 -73.987500   6.166667
    ##
    ## $message
    ## [1] "Resampling of  ewt  done on  10  permutations."
    ##
    ## $variance
    ## [1] 1670.378
    ##
    ## $p
    ## [1] 0.6363636
    ##
    ## $wins
    ## [1] NA
    ##
    ## $losses
    ## [1] NA
    ##
    ## $components
    ## [1] -6.216667  7.250000  0.000000
    ##
    ## $components_var
    ## [1] 1396.42254   58.30069    0.00000
    ##
    ## $max_time
    ## [1] 95

### wtr with 5 Resamples

It is important to note that `wtr` is a pairwise method. So, with a large number of resamples, it could take several minutes to complete execution.

    # Run wtr with 5 resamples
    result <- wintime("wtr", Time, Delta, trt, resample_num = 5)
    print(result)

    ## $trt_effect
    ## [1] 1
    ##
    ## $resample_data
    ## [1] 1.777778 6.000000 2.666667 1.000000 1.000000
    ##
    ## $message
    ## [1] "Resampling of  wtr  done on  5  bootstraps."
    ##
    ## $variance
    ## [1] 4.324691
    ##
    ## $p
    ## [1] 0.5
    ##
    ## $wins
    ## [1] 9
    ##
    ## $losses
    ## [1] 9
    ##
    ## $components
    ## [1] NA NA NA
    ##
    ## $components_var
    ## [1] NA NA NA
    ##
    ## $max_time
    ## [1] NA NA NA

## Resampleing Cont.

As we mentioned above, each win time method is set up with a default resampling technique. This can be overridden by passing the optional `resample` argument. However, this is not recommended. By changing the resampling technique, a user will receive a warning message.

For example, if we want to run the ewt method with bootstraps, we can do so by passing “boot” as the value for `resample`.

    # Run ewt on 10 bootstraps
    result <- wintime("ewt", Time, Delta, trt, resample_num = 10, resample = "boot")

    ## Warning in wintime("ewt", Time, Delta, trt, resample_num = 10, resample =
    ## "boot"): For this method, it is recommended to use a KM model and to resample
    ## using permutations. These are set as defaults.

    print(result)

    ## $trt_effect
    ## [1] 1.033333
    ##
    ## $resample_data
    ##  [1]  13.097222 -22.285714   9.000000 -12.000000  44.000000 -21.666667
    ##  [7]   1.166667  -3.685714   6.190476  11.404762
    ##
    ## $message
    ## [1] "Resampling of  ewt  done on  10  bootstraps."
    ##
    ## $variance
    ## [1] 379.8179
    ##
    ## $p
    ## [1] 0.6363636
    ##
    ## $wins
    ## [1] NA
    ##
    ## $losses
    ## [1] NA
    ##
    ## $components
    ## [1] -6.216667  7.250000  0.000000
    ##
    ## $components_var
    ## [1] 465.71943  36.27037   0.00000
    ##
    ## $max_time
    ## [1] 95

## Survival Models

The `wintime` package contains two functions that estimate the state probabilities for each arm. These will be demonstrated in the next section. Each non-pairwise method requires an estimation of the state probabilities. These are calculated using either a Markov model or a Kaplan-Meier model. Because each method is set up with a default model, no input is required. Although, if a user wishes to use one over the other, they may do so by passing the optional `model` argument into the `wintime` function. This will trigger a warning message indicating that this combination of `type` and `model` is not recommended.

For example, if we want to run the ewtr method using a Kaplan-Meier model, we can do so by passing “km” as the value for `model`.

    # Run ewtr with a KM model
    result <- wintime("ewtr", Time, Delta, trt, cov = cov, model = "km")

    ## Warning in wintime("ewtr", Time, Delta, trt, cov = cov, model = "km"): Results
    ## with a KM model are meaningless! For this method, you must use a Markov model.
    ## This is set as a default.

    print(result)

    ## $trt_effect
    ##       trt
    ## -50.99168
    ##
    ## $resample_data
    ## [1] NA
    ##
    ## $message
    ## NULL
    ##
    ## $variance
    ## [1] NaN
    ##
    ## $p
    ## trt
    ## NaN
    ##
    ## $wins
    ## [1] NA
    ##
    ## $losses
    ## [1] NA
    ##
    ## $components
    ## [1] -44.13786  -9.52684   0.00000
    ##
    ## $components_var
    ## [1] 927.078     NaN     NaN
    ##
    ## $max_time
    ## [1] NA NA NA

## Model Functions

To use either the `markov` or `km` functions, we need the number of control arm patients, the number of treatment arm patients, the number of endpoints, a matrix of event times, and a matrix of event indicators. Both functions return a list with eight elements: a matrix of control arm state probabilities, a matrix of treatment arm state probabilities, a vector of unique control arm event times, a vector of unique treatment arm event times, the number of unique control arm event times, the number of unique treatment arm event times, the control arm max follow time, and the treatment arm max follow time.

### Parameters

The event time and indicator matrices are already defined as `Time` and `Delta` (see ‘Example Data’ section above). The treatment arm indicator vector, `trt`, is not required for these functions, but it is useful in defining other parameters. This is also defined in the ‘Example Data’ section.

    # Number of control arm patients
    n0 <- sum(trt == 0)

    # Number of treatment arm patients
    n1 <- sum(trt == 1)

    # Number of endpoints
    m <- nrow(Time)

### markov Function

    # Run markov
    result <- markov(n0, n1, m, Time, Delta)

    # Control arm probabilities
    dist0 <- result[[1]]
    cat("dist0 =", "\n")

    ## dist0 =

    print(dist0)

    ##      [,1] [,2] [,3] [,4] [,5] [,6] [,7]
    ## [1,]  0.6  0.6  0.6  0.6  0.3  0.3  0.3
    ## [2,]  0.4  0.4  0.4  0.4  0.4  0.4  0.4
    ## [3,]  0.0  0.0  0.0  0.0  0.3  0.3  0.3
    ## [4,]  0.0  0.0  0.0  0.0  0.0  0.0  0.0

    # Treatment arm probabilities
    dist1 <- result[[2]]
    cat("dist1 =", "\n")

    ## dist1 =

    print(dist1)

    ##      [,1] [,2]      [,3]      [,4]      [,5]      [,6]      [,7]      [,8]
    ## [1,]  0.8  0.8 0.5333333 0.2666667 0.2666667 0.2666667 0.2666667 0.2666667
    ## [2,]  0.2  0.2 0.2000000 0.4666667 0.4666667 0.0000000 0.0000000 0.0000000
    ## [3,]  0.0  0.0 0.2666667 0.2666667 0.2666667 0.7333333 0.7333333 0.7333333
    ## [4,]  0.0  0.0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
    ##           [,9]
    ## [1,] 0.2666667
    ## [2,] 0.0000000
    ## [3,] 0.7333333
    ## [4,] 0.0000000

    # Unique control arm event times
    untimes0 <- result[[3]]
    cat("untimes0 =", "\n")

    ## untimes0 =

    print(untimes0)

    ## [1]  29  44  69  95 128 186 435

    # Unique treatment arm event times
    untimes1 <- result[[4]]
    cat("untimes1 =", "\n")

    ## untimes1 =

    print(untimes1)

    ## [1]   11   33   66  102  117  153  270  380 1063

    # Number of unique control arm event times
    nuntimes0 <- result[[5]]
    cat("nuntimes0 =", "\n")

    ## nuntimes0 =

    print(nuntimes0)

    ## [1] 7

    # Number of unique treatment arm event times
    nuntimes1 <- result[[6]]
    cat("nuntimes1 =", "\n")

    ## nuntimes1 =

    print(nuntimes1)

    ## [1] 9

    # Control arm max follow time
    max_follow0 <- result[[7]]
    cat("max_follow0 =", "\n")

    ## max_follow0 =

    print(max_follow0)

    ## [1] 95

    # Treatment arm max follow time
    max_follow1 <- result[[8]]
    cat("max_follow1 =", "\n")

    ## max_follow1 =

    print(max_follow1)

    ## [1] 380

    # Combined arm probabilities
    dist2 <- result[[9]]
    cat("dist2 =", "\n")

    ## dist2 =

    print(dist2)

    ##      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
    ## [1,]  0.9  0.7  0.7  0.7 0.56 0.56 0.56 0.42 0.42  0.28  0.28  0.28  0.28  0.28
    ## [2,]  0.1  0.3  0.3  0.3 0.30 0.30 0.30 0.44 0.44  0.44  0.00  0.00  0.00  0.00
    ## [3,]  0.0  0.0  0.0  0.0 0.14 0.14 0.14 0.14 0.14  0.28  0.72  0.72  0.72  0.72
    ## [4,]  0.0  0.0  0.0  0.0 0.00 0.00 0.00 0.00 0.00  0.00  0.00  0.00  0.00  0.00
    ##      [,15] [,16]
    ## [1,]  0.28  0.28
    ## [2,]  0.00  0.00
    ## [3,]  0.72  0.72
    ## [4,]  0.00  0.00

    # Unique combined arm event times
    untimes2 <- result[[10]]
    cat("untimes2 =", "\n")

    ## untimes2 =

    print(untimes2)

    ##  [1]   11   29   33   44   66   69   95  102  117  128  153  186  270  380  435
    ## [16] 1063

    # Number of unique combined arm event times
    nuntimes2 <- result[[11]]
    cat("nuntimes2 =", "\n")

    ## nuntimes2 =

    print(nuntimes2)

    ## [1] 16

    # Combined arm max follow time
    max_follow2 <- result[[12]]
    cat("max_follow2 =", "\n")

    ## max_follow2 =

    print(max_follow2)

    ## [1] 380

    # Combined arm transition probabilities
    trans_prob2 <- result[[13]]
    cat("trans_prob2 =", "\n")

    ## trans_prob2 =

    print(trans_prob2)

    ## , , 1
    ##
    ##      [,1] [,2] [,3]
    ## [1,]  0.1    0    0
    ## [2,] -1.0   -1   -1
    ## [3,] -1.0   -1   -1
    ##
    ## , , 2
    ##
    ##            [,1] [,2] [,3]
    ## [1,]  0.2222222    0    0
    ## [2,]  0.0000000    0    0
    ## [3,] -1.0000000   -1   -1
    ##
    ## , , 3
    ##
    ##      [,1] [,2] [,3]
    ## [1,]    0    0    0
    ## [2,]    0    0    0
    ## [3,]   -1   -1   -1
    ##
    ## , , 4
    ##
    ##      [,1] [,2] [,3]
    ## [1,]    0    0    0
    ## [2,]    0    0    0
    ## [3,]   -1   -1   -1
    ##
    ## , , 5
    ##
    ##      [,1] [,2] [,3]
    ## [1,]    0  0.2    0
    ## [2,]    0  0.0    0
    ## [3,]   -1 -1.0   -1
    ##
    ## , , 6
    ##
    ##      [,1] [,2] [,3]
    ## [1,]    0    0    0
    ## [2,]    0    0    0
    ## [3,]    0    0    0
    ##
    ## , , 7
    ##
    ##      [,1] [,2] [,3]
    ## [1,]    0    0    0
    ## [2,]    0    0    0
    ## [3,]    0    0    0
    ##
    ## , , 8
    ##
    ##      [,1] [,2] [,3]
    ## [1,] 0.25    0    0
    ## [2,] 0.00    0    0
    ## [3,] 0.00    0    0
    ##
    ## , , 9
    ##
    ##      [,1] [,2] [,3]
    ## [1,]    0    0    0
    ## [2,]    0    0    0
    ## [3,]    0    0    0
    ##
    ## , , 10
    ##
    ##      [,1]      [,2] [,3]
    ## [1,]    0 0.3333333    0
    ## [2,]    0 0.0000000    0
    ## [3,]    0 0.0000000    0
    ##
    ## , , 11
    ##
    ##      [,1] [,2] [,3]
    ## [1,]    0    0    0
    ## [2,]    0    1    0
    ## [3,]    0    0    0
    ##
    ## , , 12
    ##
    ##      [,1] [,2] [,3]
    ## [1,]    0    0    0
    ## [2,]   -1   -1   -1
    ## [3,]    0    0    0
    ##
    ## , , 13
    ##
    ##      [,1] [,2] [,3]
    ## [1,]    0    0    0
    ## [2,]   -1   -1   -1
    ## [3,]    0    0    0
    ##
    ## , , 14
    ##
    ##      [,1] [,2] [,3]
    ## [1,]    0    0    0
    ## [2,]   -1   -1   -1
    ## [3,]    0    0    0
    ##
    ## , , 15
    ##
    ##      [,1] [,2] [,3]
    ## [1,]   -1   -1   -1
    ## [2,]   -1   -1   -1
    ## [3,]    0    0    0
    ##
    ## , , 16
    ##
    ##      [,1] [,2] [,3]
    ## [1,]   -1   -1   -1
    ## [2,]   -1   -1   -1
    ## [3,]    0    0    0

### km Function

    # Run km
    result <- km(n0, n1, m, Time, Delta)

    # Control arm probabilities
    dist0 <- result[[1]]
    cat("dist0 =", "\n")

    ## dist0 =

    print(dist0)

    ##      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
    ## [1,]  0.6  0.6  0.6  0.6    0    0    0    0    0     0     0     0     0     0
    ## [2,]  0.4  0.4  0.4  0.4    0    0    0    0    0     0     0     0     0     0
    ## [3,]  0.0  0.0  0.0  0.0    0    0    0    0    0     0     0     0     0     0
    ## [4,]  0.0  0.0  0.0  0.0    0    0    0    0    0     0     0     0     0     0

    # Treatment arm probabilities
    dist1 <- result[[2]]
    cat("dist1 =", "\n")

    ## dist1 =

    print(dist1)

    ##      [,1] [,2]      [,3]      [,4]      [,5]      [,6] [,7] [,8] [,9] [,10]
    ## [1,]  0.8  0.8 0.5333333 0.2666667 0.2666667 0.2666667    0    0    0     0
    ## [2,]  0.2  0.2 0.2166667 0.4833333 0.4833333 0.1083333    0    0    0     0
    ## [3,]  0.0  0.0 0.2500000 0.2500000 0.2500000 0.6250000    0    0    0     0
    ## [4,]  0.0  0.0 0.0000000 0.0000000 0.0000000 0.0000000    0    0    0     0
    ##      [,11] [,12] [,13] [,14] [,15]
    ## [1,]     0     0     0     0     0
    ## [2,]     0     0     0     0     0
    ## [3,]     0     0     0     0     0
    ## [4,]     0     0     0     0     0

    # Unique control arm event times
    untimes0 <- result[[3]]
    cat("untimes0 =", "\n")

    ## untimes0 =

    print(untimes0)

    ## [1] 29 44 69 95

    # Unique treatment arm event times
    untimes1 <- result[[4]]
    cat("untimes1 =", "\n")

    ## untimes1 =

    print(untimes1)

    ## [1]  11  33  66 102 117 153

    # Number of unique control arm event times
    nuntimes0 <- result[[5]]
    cat("nuntimes0 =", "\n")

    ## nuntimes0 =

    print(nuntimes0)

    ## [1] 4

    # Number of unique treatment arm event times
    nuntimes1 <- result[[6]]
    cat("nuntimes1 =", "\n")

    ## nuntimes1 =

    print(nuntimes1)

    ## [1] 6

    # Control arm max follow time
    max_follow0 <- result[[7]]
    cat("max_follow0 =", "\n")

    ## max_follow0 =

    print(max_follow0)

    ## [1] 95

    # Treatment arm max follow time
    max_follow1 <- result[[8]]
    cat("max_follow1 =", "\n")

    ## max_follow1 =

    print(max_follow1)

    ## [1] 153

    # Combined arm probabilities
    dist2 <- result[[9]]
    cat("dist2 =", "\n")

    ## dist2 =

    print(dist2)

    ##      [,1] [,2] [,3] [,4]  [,5]  [,6]  [,7]  [,8]  [,9]   [,10]  [,11]
    ## [1,]  0.9  0.7  0.7  0.7 0.560 0.560 0.560 0.420 0.420 0.28000 0.2800
    ## [2,]  0.1  0.3  0.3  0.3 0.315 0.315 0.315 0.455 0.455 0.37625 0.1575
    ## [3,]  0.0  0.0  0.0  0.0 0.125 0.125 0.125 0.125 0.125 0.34375 0.5625
    ## [4,]  0.0  0.0  0.0  0.0 0.000 0.000 0.000 0.000 0.000 0.00000 0.0000

    # Unique combined arm event times
    untimes2 <- result[[10]]
    cat("untimes2 =", "\n")

    ## untimes2 =

    print(untimes2)

    ##  [1]  11  29  33  44  66  69  95 102 117 128 153

    # Number of unique combined arm event times
    nuntimes2 <- result[[11]]
    cat("nuntimes2 =", "\n")

    ## nuntimes2 =

    print(nuntimes2)

    ## [1] 11

    # Combined arm max follow time
    max_follow2 <- result[[12]]
    cat("max_follow2 =", "\n")

    ## max_follow2 =

    print(max_follow2)

    ## [1] 153

    # Combined arm KM
    comkm <- result[[13]]
    cat("comkm =", "\n")

    ## comkm =

    print(comkm)

    ##      [,1] [,2] [,3] [,4]  [,5]  [,6]  [,7]  [,8]  [,9]   [,10]  [,11]
    ## [1,]  1.0  1.0  1.0  1.0 1.000 1.000 1.000 1.000 1.000 1.00000 1.0000
    ## [2,]  1.0  1.0  1.0  1.0 0.875 0.875 0.875 0.875 0.875 0.65625 0.4375
    ## [3,]  0.9  0.7  0.7  0.7 0.560 0.560 0.560 0.420 0.420 0.28000 0.2800