library(rpart) library(survival) library(ipred) source("func2.R") options(contrasts=c("contr.treatment","contr.poly")) ## Bring in data - # need covariates in a matrix # survival time in days or months # censoring time # covariates to include in \bar{G} # cross-validation level (vfold) # independent test sample size # As an example - the library ipred is called and the dataset GBSG2 is used to illustrate the code data(GBSG2) attach(GBSG2) # put all data in a list to call function comb.dat <- list() comb.dat[[1]] <- as.numeric(time) comb.dat[[2]] <- as.numeric(cens) comb.dat[[3]] <- data.frame(GBSG2[,1:8]) comb.dat[[4]] <- data.frame(horTh=horTh, tgrade=tgrade) vfold <- 5 ind.test <- T # BEGIN CROSS-VALIDATION LOOP #rename variables for use within loop w <- comb.dat[[3]] delta <- comb.dat[[2]] ttilde <- comb.dat[[1]] deltac <- 1 - delta g.set <- comb.dat[[4]] ### Set up cross validation retaining censoring percentage v <- ifelse(ind.test=="TRUE",vfold+1,vfold) test.set.ind <- vfold+1 get.sam <- rep(c(1:v),sum(delta==1)/v) if(length(get.sam)