## ### Using 12 cores
## ### Using doParallelMC as backend

References

Load packages

library(tidyverse)
library(stepp)
library(randomForestSRC)

Prepare RCT data

data(veteran, package = "randomForestSRC")
veteran <- as_data_frame(veteran)
veteran
## # A tibble: 137 x 8
##      trt celltype  time status karno diagtime   age prior
##    <int>    <int> <int>  <int> <int>    <int> <int> <int>
##  1     1        1    72      1    60        7    69     0
##  2     1        1   411      1    70        5    64    10
##  3     1        1   228      1    60        3    38     0
##  4     1        1   126      1    60        9    63    10
##  5     1        1   118      1    70       11    65    10
##  6     1        1    10      1    20        5    49     0
##  7     1        1    82      1    40       10    69    10
##  8     1        1   110      1    80       29    68     0
##  9     1        1   314      1    50       18    43     0
## 10     1        1   100      0    70        6    70     0
## # ... with 127 more rows
veteran                package:survival                R Documentation
Veterans' Administration Lung Cancer study
Description:
     Randomised trial of two treatment regimens for lung cancer.  This
     is a standard survival analysis data set.
Format:
       trt:       1=standard 2=test                            
       celltype:  1=squamous,  2=smallcell,  3=adeno,  4=large 
       time:      survival time                                
       status:    censoring status                             
       karno:     Karnofsky performance score (100=good)       
       diagtime:  months from diagnosis to randomisation       
       age:       in years                                     
       prior:     prior therapy 0=no, 10=yes                   
Source:
     D Kalbfleisch and RL Prentice (1980), _The Statistical Analysis of
     Failure Time Data_.  Wiley, New York.

STEPP

## create the stmodelKM object
model_stepp_km <- with(veteran,
                       stepp.KM(coltrt = trt, survTime = time, censor = status, trts = c(1,2), timePoint = 100))
## create the stepp window object
## subpopulation size is 200 and allows only 50 patients between overlapping windows
win <- stepp.win(type = "sliding", r1 = 5, r2 = 20, basedon = "all")
## create a stepp subpopulation objec
subpop <- stepp.subpop(swin = win, cov = veteran$age)
summary(subpop)
## Window type:  sliding
##         Number of patients per subpopulation (patspop r2): 20
## Largest number of patients in common among consecutive subpopulations(minpatspop r1): 5
##       Number Of Subpopulations Created : 7
## 
## Subpopulation Summary Information (including all treatments)
##                                   Covariate Summary                  Sample
##      Subpopulation        Median       Minimum       Maximum          Size
##            1               39.00       34.0000       43.0000            20
##            2               48.00       43.0000       52.0000            23
##            3               55.50       51.0000       60.0000            26
##            4               62.00       61.0000       63.0000            26
##            5               65.00       64.0000       66.0000            21
##            6               68.00       67.0000       70.0000            23
##            7               71.00       70.0000       81.0000            12
## The constructor to generate a complete steppes object with effect
## estimates and test statistics
res <- stepp.test(subpop = subpop, model = model_stepp_km, nperm = 2500, showstatus = FALSE)
summary(res)
## Window type:  sliding
##         Number of patients per subpopulation (patspop r2): 20
## Largest number of patients in common among consecutive subpopulations(minpatspop r1): 5
##       Number Of Subpopulations Created : 7
## 
## Subpopulation Summary Information (including all treatments)
##                                   Covariate Summary                  Sample
##      Subpopulation        Median       Minimum       Maximum          Size
##            1               39.00       34.0000       43.0000            20
##            2               48.00       43.0000       52.0000            23
##            3               55.50       51.0000       60.0000            26
##            4               62.00       61.0000       63.0000            26
##            5               65.00       64.0000       66.0000            21
##            6               68.00       67.0000       70.0000            23
##            7               71.00       70.0000       81.0000            12
## 
## Treatments Sample Size Information (with only specified treatments)
##       Subpopulation     trt 1   trt 2    Total
##            1             12       8       20
##            2             12      11       23
##            3             12      14       26
##            4             13      13       26
##            5             11      10       21
##            6             12      11       23
##            7              3       9       12
## 
## (To display subpopulation distribution together with the first STEPP Plot, use the subplot option in STEPP_Plot.)
plot(res)