knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Introduction

We apply the package stackBagg to a data set The Bone Marrow Transplant Data (bmt) which is in the package timereg . Bone marrow transplants are a standard treatment for acute leukemia. In the recovery process patients can suffer from Infections, toxicity, and (after allogeneic HSCT only), graft-vs.-host disease (GVHD) being the main causes of death. We are interested in predicting the time to death related to treatment where the risk of relapse is a competing risk.

Setup

We load the package stackBagg and timereg and we load the data set bmt

library(stackBagg)
library(timereg)
bmt.data <- data(bmt)
summary(bmt)
dim(bmt)
train.set <- sample(1:nrow(bmt), floor(.9*nrow(bmt)), replace=FALSE) 
test.set <- setdiff(1:nrow(bmt), train.set)
bmt.train <- data.frame(bmt[train.set,])
bmt.test <- data.frame(bmt[test.set,]) 
tao=7

Let's define the library of algorithms:

ens.library <-stackBagg::algorithms()

We set the covariates that we include in the models:

xnam <- names(bmt)[-(1:2)]
xnam

Now, we are ready to predict the outcome of interest using all the algorithms:

pred.bmt=stackBagg::stackBagg(train.data = bmt.train,test.data = bmt.test,xnam=xnam,tao=7,weighting ="CoxPH" ,folds =5,ens.library = ens.library )

The assessment of predictive performance using the IPCW AUC is:

pred.bmt$auc_ipcwBagg

Now let s take a look at prediction of the algorithms that allows for weights natively:

head(pred.bmt$prediction_native_weights,5)

and their performance is:

pred.bmt$auc_native_weights

The prediction of the survival based methods

head(pred.bmt$prediction_survival,5)
pred.bmt$auc_survival

Lastly, we could see the performance of the algorithms if we were to discard the censored observations

pred.discard <- stackBagg::prediction_discard(train.data = bmt.train,test.data = bmt.test,xnam=names(bmt)[-(1:2)],tao=7,ens.library=ens.library)
head(pred.discard$prediction_discard)
pred.discard$auc_discard

The ROC curve of the stack is

stackBagg::plot_roc(time=bmt.test$time,delta = bmt.test$cause,marker =pred.bmt$prediction_ensBagg[,"Stack"],wts=pred.bmt$wts_test,tao=7,method = "ipcw")

The Random Forest ROC curve is

stackBagg::plot_roc(time=bmt.test$time,delta = bmt.test$cause,marker =pred.bmt$prediction_ensBagg[,"ens.randomForest"],wts=pred.bmt$wts_test,tao=7,method = "ipcw")

The Random Forest survival ROC curve is

stackBagg::plot_roc(time=bmt.test$time,delta = bmt.test$cause,marker =pred.bmt$prediction_survival[,"Random Forest"],wts=pred.bmt$wts_test,tao=7,method = "ipcw")

The Random Forest natively weighted ROC curve is

stackBagg::plot_roc(time=bmt.test$time,delta = bmt.test$cause,marker =pred.bmt$prediction_native_weights[,"ens.randomForest"],wts=pred.bmt$wts_test,tao=7,method = "ipcw")

The Random Forest discarding censored observations

stackBagg::plot_roc(time=bmt.test$time,delta = bmt.test$cause,marker =pred.discard$prediction_discard[,"ens.randomForest"],tao=7,method = "discard")


pablogonzalezginestet/ensBagg documentation built on Aug. 25, 2023, 3:23 a.m.