Skip to contents

Orchestrates the cross-validation, metalearner optimization, and prediction for an ensemble of survival base learners.

Usage

SuperSurv(
  time,
  event,
  X,
  newdata = NULL,
  new.times,
  event.library,
  cens.library,
  id = NULL,
  verbose = FALSE,
  control = list(),
  cvControl = list(),
  obsWeights = NULL,
  metalearner = "brier",
  selection = "ensemble",
  nFolds = 10,
  parallel = FALSE
)

Arguments

time

Observed follow-up time.

event

Observed event indicator.

X

Training covariate data.frame.

newdata

Test covariate data.frame for prediction (defaults to X).

new.times

Times at which to obtain predicted survivals.

event.library

Character vector of prediction algorithms for the event.

cens.library

Character vector of prediction algorithms for censoring.

id

Cluster identification variable.

verbose

Logical. If TRUE, prints progress messages.

control

List of control parameters for the Super Learner.

cvControl

List of control parameters for cross-validation.

obsWeights

Observation weights.

metalearner

Character string specifying the optimizer (e.g., "least_squares").

selection

Character. Specifies how the meta-learner combines the base models. Use "ensemble" (default) to calculate a weighted average (convex combination) of the base learners. Use "best" to act as a Discrete Super Learner, which assigns a weight of 1.0 to the single model with the lowest cross-validated risk.

nFolds

Number of cross-validation folds (default: 10).

parallel

Logical. If TRUE, uses future.apply for parallel execution.

Value

A list of class SuperSurv containing:

  • call: The matched function call.

  • event.predict: Matrix of in-sample cross-validated survival predictions.

  • cens.predict: Matrix of in-sample cross-validated censoring predictions.

  • event.coef: Numeric vector of optimized ensemble weights for the event.

  • cens.coef: Numeric vector of optimized ensemble weights for censoring.

  • event.library.predict: 3D array of cross-validated predictions from individual event learners.

  • event.libraryNames: Data frame detailing the algorithms and screeners used.

  • event.fitLibrary: List of the fitted base learner models (if saveFitLibrary = TRUE).

  • times: The time grid used for evaluation.

Examples

if (requireNamespace("glmnet", quietly = TRUE)) {
  data("metabric", package = "SuperSurv")
  dat <- metabric[1:80, ]
  x_cols <- grep("^x", names(dat))[1:5]
  X <- dat[, x_cols, drop = FALSE]
  new.times <- seq(20, 120, by = 20)

  fit <- SuperSurv(
    time = dat$duration,
    event = dat$event,
    X = X,
    newdata = X,
    new.times = new.times,
    event.library = c("surv.coxph", "surv.ridge"),
    cens.library = c("surv.coxph"),
    control = list(saveFitLibrary = TRUE)
  )

  fit$event.library.predict
}
#> , , 1
#> 
#>            [,1]      [,2]      [,3]       [,4]       [,5]       [,6]
#>  [1,] 0.9700650 0.8875504 0.7717069 0.72395128 0.61116122 0.59792836
#>  [2,] 0.9805888 0.9259467 0.8460772 0.81192611 0.72790811 0.71770347
#>  [3,] 0.9651618 0.8700719 0.7390725 0.68599088 0.56299045 0.54879396
#>  [4,] 0.9761692 0.9096740 0.8141076 0.77386431 0.67653839 0.66488716
#>  [5,] 0.9677792 0.8793698 0.7563380 0.70602374 0.58824219 0.57452850
#>  [6,] 0.9736595 0.9005289 0.7964322 0.75297733 0.64890242 0.63654580
#>  [7,] 0.9752753 0.9064089 0.8077728 0.76636555 0.66657105 0.65465936
#>  [8,] 0.9561697 0.8386857 0.6823761 0.62102711 0.48377082 0.46840340
#>  [9,] 0.9764098 0.9105543 0.8158199 0.77589374 0.67924465 0.66766530
#> [10,] 0.9545174 0.8330116 0.6723866 0.60971519 0.47040334 0.45489354
#> [11,] 0.9496885 0.8165930 0.6439281 0.57771768 0.43329593 0.41748179
#> [12,] 0.9672778 0.8775831 0.7530036 0.70214606 0.58332461 0.56951298
#> [13,] 0.9697557 0.8864400 0.7696110 0.72150125 0.60801129 0.59470999
#> [14,] 0.9735555 0.9001511 0.7957066 0.75212235 0.64777964 0.63539548
#> [15,] 0.9586661 0.8473134 0.6977180 0.63847950 0.50464581 0.48953379
#> [16,] 0.9704225 0.8888349 0.7741351 0.72679185 0.61482026 0.60166781
#> [17,] 0.9811924 0.9281857 0.8505282 0.81725373 0.73520113 0.72521559
#> [18,] 0.9333584 0.7628506 0.5554010 0.48045424 0.32714787 0.31129461
#> [19,] 0.9813461 0.9287565 0.8516648 0.81861531 0.73706901 0.72714012
#> [20,] 0.9689175 0.8834364 0.7639571 0.71490016 0.59955238 0.58607100
#> [21,] 0.9692508 0.8846300 0.7662012 0.71751872 0.60290303 0.58949234
#> [22,] 0.9683193 0.8812975 0.7599446 0.71022277 0.59358330 0.57997810
#> [23,] 0.9623370 0.8601194 0.7208298 0.66494912 0.53688027 0.52223852
#> [24,] 0.9634021 0.8638620 0.7276610 0.67281319 0.54658866 0.53210591
#> [25,] 0.7973732 0.4111682 0.1450374 0.09011233 0.02551431 0.02167484
#> [26,] 0.9722567 0.8954471 0.7867007 0.74152625 0.63392028 0.62120354
#> [27,] 0.9579379 0.8447899 0.6932117 0.63334333 0.49847092 0.48327923
#> [28,] 0.9704639 0.8889838 0.7744170 0.72712171 0.61524566 0.60210262
#> [29,] 0.9646462 0.8682491 0.7357129 0.68210604 0.55813781 0.54385435
#> [30,] 0.9683455 0.8813914 0.7601205 0.71042775 0.59384444 0.58024461
#> [31,] 0.9663015 0.8741115 0.7465473 0.69464975 0.57385833 0.55986347
#> [32,] 0.9640272 0.8660640 0.7316966 0.67746762 0.55236279 0.53797832
#> [33,] 0.9223241 0.7280600 0.5018412 0.42340470 0.26981489 0.25455020
#> [34,] 0.9587546 0.8476203 0.6982671 0.63910588 0.50540067 0.49029862
#> [35,] 0.9593479 0.8496809 0.7019602 0.64332199 0.51049155 0.49545809
#> [36,] 0.9771642 0.9133186 0.8212101 0.78228892 0.68779692 0.67644794
#> [37,] 0.9762705 0.9100446 0.8148282 0.77471822 0.67767664 0.66605557
#> [38,] 0.9566820 0.8404510 0.6855002 0.62457320 0.48798776 0.47266872
#> [39,] 0.9759839 0.9089965 0.8127908 0.77230437 0.67446074 0.66275466
#> [40,] 0.9780130 0.9164366 0.8273127 0.78954194 0.69754085 0.68646025
#> [41,] 0.9646555 0.8682817 0.7357731 0.68217558 0.55822454 0.54394261
#> [42,] 0.9754297 0.9069722 0.8088638 0.76765590 0.66828256 0.65641511
#> [43,] 0.9661080 0.8734247 0.7452736 0.69317273 0.57199944 0.55796943
#> [44,] 0.9718391 0.8939383 0.7838240 0.73814780 0.62952310 0.61670370
#> [45,] 0.9553965 0.8360271 0.6776857 0.61571067 0.47747225 0.46203564
#> [46,] 0.9723422 0.8957562 0.7872909 0.74221972 0.63482417 0.62212869
#> [47,] 0.9614940 0.8571658 0.7154632 0.65878384 0.52931104 0.51455081
#> [48,] 0.9723361 0.8957340 0.7872483 0.74216972 0.63475898 0.62206197
#> [49,] 0.9685384 0.8820807 0.7614125 0.71193326 0.59576377 0.58220349
#> [50,] 0.9382690 0.7787253 0.5808162 0.50801215 0.35617683 0.34020019
#> [51,] 0.9471122 0.8079325 0.6291842 0.56127587 0.41463987 0.39872574
#> [52,] 0.9653626 0.8707827 0.7403849 0.68750957 0.56489142 0.55072952
#> [53,] 0.9758352 0.9084530 0.8117355 0.77105471 0.67279791 0.66104815
#> [54,] 0.9509140 0.8207366 0.6510477 0.58569062 0.44244383 0.42669194
#> [55,] 0.9678553 0.8796411 0.7568451 0.70661392 0.58899189 0.57529330
#> [56,] 0.9697381 0.8863768 0.7694918 0.72136191 0.60783232 0.59452716
#> [57,] 0.9689737 0.8836378 0.7643356 0.71534167 0.60011687 0.58664734
#> [58,] 0.9275221 0.7442981 0.5264748 0.44946616 0.29553446 0.27994553
#> [59,] 0.9556087 0.8367562 0.6789702 0.61716576 0.47919332 0.46377525
#> [60,] 0.9696117 0.8859235 0.7686371 0.72036333 0.60655020 0.59321742
#> [61,] 0.9713819 0.8922887 0.7806850 0.73446496 0.62474174 0.61181230
#> [62,] 0.9774237 0.9142711 0.8230718 0.78450025 0.69076270 0.67949473
#> [63,] 0.9170021 0.7117092 0.4776788 0.39814641 0.24566747 0.23080489
#> [64,] 0.9685732 0.8822052 0.7616459 0.71220527 0.59611076 0.58255766
#> [65,] 0.9401464 0.7848591 0.5908008 0.51892086 0.36790049 0.35190425
#> [66,] 0.9662002 0.8737517 0.7458800 0.69387585 0.57288409 0.55887077
#> [67,] 0.9642751 0.8669386 0.7333026 0.67932170 0.55466872 0.54032425
#> [68,] 0.9618095 0.8582704 0.7174676 0.66108521 0.53213215 0.51741552
#> [69,] 0.9527257 0.8268913 0.6617005 0.59766031 0.45630036 0.44065885
#> [70,] 0.9758005 0.9083262 0.8114893 0.77076319 0.67241022 0.66065029
#> [71,] 0.9771012 0.9130877 0.8207591 0.78175347 0.68707946 0.67571096
#> [72,] 0.9763523 0.9103439 0.8154105 0.77540836 0.67859705 0.66700045
#> [73,] 0.9739871 0.9017188 0.7987201 0.75567457 0.65244886 0.64017981
#> [74,] 0.9735417 0.9001012 0.7956107 0.75200936 0.64763131 0.63524352
#> [75,] 0.9671950 0.8772880 0.7524536 0.70150681 0.58251530 0.56868774
#> [76,] 0.9506040 0.8196868 0.6492399 0.58366412 0.44011245 0.42434389
#> [77,] 0.9764282 0.9106218 0.8159514 0.77604964 0.67945270 0.66787888
#> [78,] 0.9670820 0.8768859 0.7517045 0.70063645 0.58141400 0.56756483
#> [79,] 0.9740552 0.9019662 0.7991964 0.75623629 0.65318828 0.64093759
#> [80,] 0.9646597 0.8682968 0.7358007 0.68220756 0.55826443 0.54398321
#> 
#> , , 2
#> 
#>            [,1]      [,2]      [,3]      [,4]      [,5]      [,6]
#>  [1,] 0.9643506 0.8686855 0.7472102 0.6979231 0.5834153 0.5700587
#>  [2,] 0.9679272 0.8812466 0.7697494 0.7239963 0.6163733 0.6036863
#>  [3,] 0.9627565 0.8631301 0.7373522 0.6865768 0.5692622 0.5556427
#>  [4,] 0.9650443 0.8711114 0.7515362 0.7029133 0.5896765 0.5764409
#>  [5,] 0.9626628 0.8628043 0.7367763 0.6859150 0.5684402 0.5548059
#>  [6,] 0.9646004 0.8695584 0.7487654 0.6997162 0.5856626 0.5723490
#>  [7,] 0.9648457 0.8704163 0.7502954 0.7014813 0.5878775 0.5746068
#>  [8,] 0.9602895 0.8545842 0.7223199 0.6693435 0.5479880 0.5340026
#>  [9,] 0.9655154 0.8727617 0.7544864 0.7063203 0.5939641 0.5808130
#> [10,] 0.9604310 0.8550729 0.7231751 0.6703216 0.5491883 0.5352226
#> [11,] 0.9597442 0.8527041 0.7190342 0.6655877 0.5433875 0.5293277
#> [12,] 0.9623768 0.8618105 0.7350207 0.6838985 0.5659382 0.5522592
#> [13,] 0.9638129 0.8668084 0.7438719 0.6940767 0.5786045 0.5651568
#> [14,] 0.9640223 0.8675389 0.7451702 0.6955722 0.5804734 0.5670608
#> [15,] 0.9607437 0.8561530 0.7250675 0.6724871 0.5518486 0.5379270
#> [16,] 0.9638584 0.8669671 0.7441538 0.6944014 0.5790101 0.5655700
#> [17,] 0.9667396 0.8770608 0.7622000 0.7152430 0.6052416 0.5923195
#> [18,] 0.9575828 0.8452810 0.7061373 0.6508850 0.5255023 0.5111694
#> [19,] 0.9664163 0.8759240 0.7601564 0.7128770 0.6022444 0.5892605
#> [20,] 0.9632249 0.8647597 0.7402370 0.6898935 0.5733874 0.5598429
#> [21,] 0.9642774 0.8684296 0.7467547 0.6973979 0.5827578 0.5693885
#> [22,] 0.9631072 0.8643499 0.7395111 0.6890586 0.5723480 0.5587845
#> [23,] 0.9613962 0.8584102 0.7290302 0.6770260 0.5574386 0.5436114
#> [24,] 0.9619534 0.8603412 0.7324289 0.6809235 0.5622536 0.5485097
#> [25,] 0.9478795 0.8125456 0.6507001 0.5884116 0.4517673 0.4365993
#> [26,] 0.9641674 0.8680457 0.7460715 0.6966106 0.5817723 0.5683843
#> [27,] 0.9608288 0.8564470 0.7255830 0.6730772 0.5525744 0.5386649
#> [28,] 0.9645567 0.8694057 0.7484932 0.6994023 0.5852691 0.5719479
#> [29,] 0.9621567 0.8610463 0.7336721 0.6823502 0.5640196 0.5503067
#> [30,] 0.9635402 0.8658580 0.7421845 0.6921341 0.5761799 0.5626869
#> [31,] 0.9627700 0.8631770 0.7374353 0.6866723 0.5693808 0.5557635
#> [32,] 0.9618995 0.8601543 0.7320997 0.6805457 0.5617863 0.5480342
#> [33,] 0.9566161 0.8419765 0.7004346 0.6444038 0.5176817 0.5032377
#> [34,] 0.9608668 0.8565786 0.7258137 0.6733413 0.5528992 0.5389952
#> [35,] 0.9611988 0.8577268 0.7278292 0.6756498 0.5557417 0.5418856
#> [36,] 0.9662940 0.8754942 0.7593845 0.7119837 0.6011139 0.5881070
#> [37,] 0.9654691 0.8725992 0.7541957 0.7059844 0.5935409 0.5803814
#> [38,] 0.9605205 0.8553819 0.7237162 0.6709407 0.5499484 0.5359952
#> [39,] 0.9651416 0.8714518 0.7521442 0.7036152 0.5905590 0.5773407
#> [40,] 0.9666230 0.8766505 0.7614622 0.7143886 0.6041587 0.5912142
#> [41,] 0.9621154 0.8609032 0.7334197 0.6820604 0.5636608 0.5499415
#> [42,] 0.9653996 0.8723558 0.7537602 0.7054813 0.5929073 0.5797353
#> [43,] 0.9628246 0.8633669 0.7377711 0.6870582 0.5698603 0.5562517
#> [44,] 0.9643808 0.8687910 0.7473982 0.6981397 0.5836867 0.5703352
#> [45,] 0.9620629 0.8607208 0.7330982 0.6816914 0.5632040 0.5494767
#> [46,] 0.9643640 0.8687322 0.7472934 0.6980189 0.5835354 0.5701810
#> [47,] 0.9617248 0.8595485 0.7310327 0.6793219 0.5602733 0.5464949
#> [48,] 0.9647515 0.8700866 0.7497072 0.7008026 0.5870255 0.5737383
#> [49,] 0.9648222 0.8703341 0.7501486 0.7013119 0.5876649 0.5743900
#> [50,] 0.9579728 0.8466168 0.7084491 0.6535159 0.5286880 0.5144019
#> [51,] 0.9589798 0.8500731 0.7144493 0.6603537 0.5369977 0.5228374
#> [52,] 0.9624104 0.8619273 0.7352270 0.6841353 0.5662319 0.5525581
#> [53,] 0.9657440 0.8735630 0.7559211 0.7079783 0.5960543 0.5829450
#> [54,] 0.9599243 0.8533246 0.7201178 0.6668259 0.5449027 0.5308672
#> [55,] 0.9627894 0.8632443 0.7375542 0.6868090 0.5695506 0.5559364
#> [56,] 0.9635455 0.8658764 0.7422171 0.6921717 0.5762267 0.5627347
#> [57,] 0.9639561 0.8673080 0.7447596 0.6950992 0.5798820 0.5664583
#> [58,] 0.9565394 0.8417148 0.6999842 0.6438924 0.5170662 0.5026137
#> [59,] 0.9607306 0.8561076 0.7249878 0.6723959 0.5517365 0.5378130
#> [60,] 0.9631816 0.8646087 0.7399695 0.6895858 0.5730043 0.5594528
#> [61,] 0.9636388 0.8662016 0.7427943 0.6928361 0.5770556 0.5635790
#> [62,] 0.9660172 0.8745221 0.7576401 0.7099657 0.5985630 0.5855043
#> [63,] 0.9554108 0.8378700 0.6933815 0.6364049 0.5080836 0.4935103
#> [64,] 0.9632639 0.8648952 0.7404772 0.6901697 0.5737314 0.5601932
#> [65,] 0.9587925 0.8494296 0.7133302 0.6590774 0.5354434 0.5212591
#> [66,] 0.9623250 0.8616307 0.7347032 0.6835339 0.5654862 0.5517992
#> [67,] 0.9618145 0.8598595 0.7315804 0.6799500 0.5610496 0.5472847
#> [68,] 0.9620640 0.8607249 0.7331054 0.6816997 0.5632142 0.5494871
#> [69,] 0.9600527 0.8537674 0.7208915 0.6677102 0.5459857 0.5319678
#> [70,] 0.9655702 0.8729537 0.7548301 0.7067174 0.5944644 0.5813234
#> [71,] 0.9648628 0.8704762 0.7504024 0.7016046 0.5880324 0.5747647
#> [72,] 0.9650724 0.8712097 0.7517118 0.7031159 0.5899312 0.5767006
#> [73,] 0.9647693 0.8701489 0.7498184 0.7009308 0.5871865 0.5739024
#> [74,] 0.9643169 0.8685679 0.7470009 0.6976817 0.5831131 0.5697506
#> [75,] 0.9634945 0.8656985 0.7419014 0.6918084 0.5757736 0.5622732
#> [76,] 0.9599247 0.8533263 0.7201206 0.6668291 0.5449067 0.5308713
#> [77,] 0.9659514 0.8742909 0.7572256 0.7094864 0.5979577 0.5848867
#> [78,] 0.9635080 0.8657456 0.7419851 0.6919047 0.5758938 0.5623955
#> [79,] 0.9654354 0.8724810 0.7539843 0.7057402 0.5932333 0.5800678
#> [80,] 0.9624487 0.8620602 0.7354617 0.6844048 0.5665661 0.5528983
#>