Skip to contents

Generate estimates of conditional survival probability or conditional restrcited mean survival time using doubly-robust pseudo-outcome regression with SuperLearner

Usage

DR_pseudo_outcome_regression(
  time,
  event,
  X,
  newX,
  approx_times,
  S_hat,
  G_hat,
  newtimes,
  outcome,
  SL.library,
  V
)

Arguments

time

n x 1 numeric vector of observed follow-up times. If there is censoring, these are the minimum of the event and censoring times.

event

n x 1 numeric vector of status indicators of whether an event was observed.

X

n x p data.frame of observed covariate values

newX

m x p data.frame of new observed covariate values at which to obtain m predictions for the estimated algorithm. Must have the same names and structure as X.

approx_times

Numeric vector of length J2 giving times at which to approximate integral appearing in the pseudo-outcomes

S_hat

n x J2 matrix of conditional event time survival function estimates

G_hat

n x J2 matrix of conditional censoring time survival function estimates

newtimes

Numeric vector of times at which to generate oracle prediction function estimates. For outcome "survival_probability", this is the times at which the survival function is to be estimated. For outcome "restricted_survival_time", this is simply the restriction time.

outcome

Outcome type, either "survival_probability" or "restricted_survival_time"

SL.library

Super Learner library

V

Number of cross-validation folds, to be passed to SuperLearner

Value

Matrix of predictions corresponding to newX and newtimes.

Examples

# This is a small simulation example
set.seed(123)
n <- 250
X <- data.frame(X1 = rnorm(n), X2 = rbinom(n, size = 1, prob = 0.5))

T <- rexp(n, rate = exp(-2 + X[,1] - X[,2] + .5 *  X[,1] * X[,2]))
C <- rexp(n, exp(-2 -.5 * X[,1] - .25 * X[,2] + .5 * X[,1] * X[,2]))
C[C > 15] <- 15

time <- pmin(T, C)
event <- as.numeric(T <= C)

# Note that this a very small Super Learner library, for computational purposes.
SL.library <- c("SL.mean", "SL.glm")

approx_times <- c(0, sort(unique(time)))

# estimate conditional survival functions at approx_times
fit <- stackG(time = time,
              event = event,
              X = X,
              newX = X,
              newtimes = approx_times,
              direction = "prospective",
              bin_size = 0.1,
              time_basis = "continuous",
              surv_form = "PI",
              learner = "SuperLearner",
              time_grid_approx = approx_times,
              SL_control = list(SL.library = SL.library,
                                V = 3))

# use DR pseudo-outcome regression to (robustly) estimate survival at t = 5
DR_preds <- DR_pseudo_outcome_regression(time = time,
                                        event = event,
                                        X = X,
                                        newX = X,
                                        newtimes = 5,
                                        approx_times = approx_times,
                                        S_hat = fit$S_T_preds,
                                        G_hat = fit$S_C_preds,
                                        outcome = "survival_probability",
                                        SL.library = SL.library,
                                        V = 3)
DR_preds
#>                [,1]
#>   [1,]  0.717678946
#>   [2,]  0.629275538
#>   [3,]  0.150485092
#>   [4,]  0.548797775
#>   [5,]  0.533065643
#>   [6,]  0.108636652
#>   [7,]  0.668175208
#>   [8,]  1.130128400
#>   [9,]  0.975372491
#>  [10,]  0.686949376
#>  [11,]  0.240046974
#>  [12,]  0.471365958
#>  [13,]  0.684272789
#>  [14,]  0.538045226
#>  [15,]  0.940307560
#>  [16,]  0.089406689
#>  [17,]  0.434420822
#>  [18,]  1.317897945
#>  [19,]  0.379953146
#>  [20,]  0.918079525
#>  [21,]  0.853469281
#>  [22,]  0.626009552
#>  [23,]  0.842276470
#>  [24,]  0.762754921
#>  [25,]  0.958828253
#>  [26,]  1.242977085
#>  [27,]  0.567306748
#>  [28,]  0.526619255
#>  [29,]  1.096157456
#>  [30,]  0.232088984
#>  [31,]  0.677396189
#>  [32,]  0.870513268
#>  [33,]  0.328091194
#>  [34,]  0.556508132
#>  [35,]  0.347775202
#>  [36,]  0.607225483
#>  [37,]  0.419414594
#>  [38,]  0.808108686
#>  [39,]  0.873428263
#>  [40,]  0.669501189
#>  [41,]  0.977474627
#>  [42,]  0.623317652
#>  [43,]  1.130218094
#>  [44,] -0.012846040
#>  [45,]  0.468230423
#>  [46,]  1.092135157
#>  [47,]  0.675500191
#>  [48,]  0.916437227
#>  [49,]  0.582782630
#>  [50,]  0.589982660
#>  [51,]  0.499869140
#>  [52,]  0.575309617
#>  [53,]  0.803012346
#>  [54,]  0.425235485
#>  [55,]  0.851965177
#>  [56,]  0.385658930
#>  [57,]  1.206057682
#>  [58,]  0.635067895
#>  [59,]  0.758388931
#>  [60,]  0.509872979
#>  [61,]  0.466059675
#>  [62,]  0.925983697
#>  [63,]  0.880720239
#>  [64,]  0.840288101
#>  [65,]  1.078400206
#>  [66,]  0.710299564
#>  [67,]  0.447707021
#>  [68,]  0.777351746
#>  [69,]  0.544695791
#>  [70,]  0.242838564
#>  [71,]  0.922961347
#>  [72,]  1.409580986
#>  [73,]  0.522354989
#>  [74,]  0.757484821
#>  [75,]  0.975681829
#>  [76,]  0.517046782
#>  [77,]  0.643887880
#>  [78,]  0.894390948
#>  [79,]  0.743012798
#>  [80,]  0.604843053
#>  [81,]  0.789995415
#>  [82,]  0.688418927
#>  [83,]  0.890744338
#>  [84,]  0.395203516
#>  [85,]  0.850550816
#>  [86,]  0.478868610
#>  [87,]  0.274103161
#>  [88,]  0.675063035
#>  [89,]  0.878772891
#>  [90,]  0.484062933
#>  [91,]  0.525629565
#>  [92,]  0.420892193
#>  [93,]  0.727642281
#>  [94,]  0.735726518
#>  [95,]  0.203494209
#>  [96,]  0.952196038
#>  [97,]  0.206104426
#>  [98,]  0.157470068
#>  [99,]  0.854622747
#> [100,]  0.842387932
#> [101,]  0.757807550
#> [102,]  0.722783954
#> [103,]  0.633695569
#> [104,]  0.660687992
#> [105,]  0.822367290
#> [106,]  0.803589733
#> [107,]  0.777746713
#> [108,]  1.237958330
#> [109,]  0.669435755
#> [110,]  0.321702199
#> [111,]  0.945528242
#> [112,]  0.404949149
#> [113,]  1.000691085
#> [114,]  0.806409194
#> [115,]  0.652520251
#> [116,]  0.710935301
#> [117,]  0.763254236
#> [118,]  0.963021413
#> [119,]  1.018959253
#> [120,]  0.841774455
#> [121,]  0.760050390
#> [122,]  1.045127201
#> [123,]  0.922834556
#> [124,]  0.636211538
#> [125,]  0.074164478
#> [126,]  0.742161783
#> [127,]  0.504668576
#> [128,]  0.770672173
#> [129,]  0.825107481
#> [130,]  0.586754572
#> [131,]  0.404908055
#> [132,]  0.670694346
#> [133,]  0.556633275
#> [134,]  0.904618318
#> [135,]  1.117215219
#> [136,]  0.264869811
#> [137,]  1.182474547
#> [138,]  0.593493235
#> [139,]  0.280571779
#> [140,]  0.954123253
#> [141,]  0.603707505
#> [142,]  0.861714632
#> [143,]  1.212318314
#> [144,]  0.973065855
#> [145,]  0.996315979
#> [146,]  0.933633878
#> [147,]  1.182773111
#> [148,]  0.383550092
#> [149,]  0.005580680
#> [150,]  1.136008409
#> [151,]  0.580702013
#> [152,]  0.585706109
#> [153,]  0.478756034
#> [154,]  1.061427455
#> [155,]  0.823509351
#> [156,]  0.866585237
#> [157,]  0.640855558
#> [158,]  0.667351381
#> [159,]  0.530053900
#> [160,]  0.667924708
#> [161,]  0.509782808
#> [162,]  1.072347571
#> [163,]  0.904946297
#> [164,] -0.075917386
#> [165,]  0.679239961
#> [166,]  0.487849347
#> [167,]  0.621162033
#> [168,]  0.697151731
#> [169,]  0.653201456
#> [170,]  0.468916798
#> [171,]  0.625315165
#> [172,]  0.774062680
#> [173,]  0.576787164
#> [174,] -0.002005237
#> [175,]  0.766085756
#> [176,]  1.084878619
#> [177,]  0.781424221
#> [178,]  0.484569823
#> [179,]  0.450834827
#> [180,]  0.690349397
#> [181,]  1.076134547
#> [182,]  0.453450089
#> [183,]  0.885121164
#> [184,]  1.023190360
#> [185,]  0.854777771
#> [186,]  0.844311778
#> [187,]  0.494471021
#> [188,]  0.544989448
#> [189,]  0.365848700
#> [190,]  0.701303313
#> [191,]  0.510273448
#> [192,]  0.878439490
#> [193,]  0.766223158
#> [194,]  0.807310736
#> [195,]  0.918501639
#> [196,]  0.256989425
#> [197,]  0.406891064
#> [198,]  0.902568550
#> [199,]  0.731246059
#> [200,]  0.884959693
#> [201,]  0.203032543
#> [202,]  0.216405373
#> [203,]  0.638634512
#> [204,]  0.646153764
#> [205,]  0.678566121
#> [206,]  0.919004377
#> [207,]  1.002605600
#> [208,]  0.726816858
#> [209,]  0.125808238
#> [210,]  0.582129637
#> [211,]  0.759622519
#> [212,]  0.726315903
#> [213,]  0.461669350
#> [214,]  0.929661272
#> [215,]  0.833311009
#> [216,]  0.119173405
#> [217,]  0.685745297
#> [218,]  0.761195806
#> [219,]  1.122423339
#> [220,]  0.911519842
#> [221,]  0.721291604
#> [222,]  0.626135952
#> [223,]  0.494490332
#> [224,]  0.602154075
#> [225,]  0.888870075
#> [226,]  0.775546275
#> [227,]  0.980121521
#> [228,]  0.983499684
#> [229,]  0.554763871
#> [230,]  0.839489761
#> [231,]  0.044340016
#> [232,]  0.815711979
#> [233,]  0.734117447
#> [234,]  0.989203126
#> [235,]  0.721402734
#> [236,]  0.920164960
#> [237,]  0.840497669
#> [238,]  0.679398677
#> [239,]  0.480869975
#> [240,]  0.776845282
#> [241,]  1.002610721
#> [242,]  0.702081284
#> [243,]  0.167252565
#> [244,]  1.095934421
#> [245,]  0.615591830
#> [246,]  0.282376189
#> [247,]  0.818563839
#> [248,]  0.931626841
#> [249,]  0.969461925
#> [250,]  0.661606134