## Not run:
# # Start the graphics device driver to save all plots in a pdf format
# pdf(file = "Example.pdf")
# # Get the stage C prostate cancer data from the rpart package
# library(rpart)
# data(stagec)
# # Split the stages into several columns
# dataCancer <- cbind(stagec[,c(1:3,5:6)],
# gleason4 = 1*(stagec[,7] == 4),
# gleason5 = 1*(stagec[,7] == 5),
# gleason6 = 1*(stagec[,7] == 6),
# gleason7 = 1*(stagec[,7] == 7),
# gleason8 = 1*(stagec[,7] == 8),
# gleason910 = 1*(stagec[,7] >= 9),
# eet = 1*(stagec[,4] == 2),
# diploid = 1*(stagec[,8] == "diploid"),
# tetraploid = 1*(stagec[,8] == "tetraploid"),
# notAneuploid = 1-1*(stagec[,8] == "aneuploid"))
# # Remove the incomplete cases
# dataCancer <- dataCancer[complete.cases(dataCancer),]
# # Load a pre-stablished data frame with the names and descriptions of all variables
# data(cancerVarNames)
# # Get a Cox proportional hazards model using:
# # - A lax p-value
# # - 10 bootstrap loops
# # - Age as a covariate
# # - The Wilcoxon rank-sum test as the feature inclusion criterion
# cancerModel <- ForwardSelection.Model.Res(pvalue = 0.1,
# loops = 10,
# covariates = "1 + age",
# Outcome = "pgstat",
# variableList = cancerVarNames,
# data = dataCancer,
# type = "COX",
# testType= "Wilcox",
# timeOutcome = "pgtime")
# # Remove not significant variables from the previous model:
# # - Using a strict p-value
# # - Excluding the covariate as a candidate for feature removal
# # - Using the Wilcoxon rank-sum test as the feature removal criterion
# # - Using 50 bootstrap loops
# reducedCancerModel <- bootstrapVarElimination_Res(object = cancerModel$final.model,
# pvalue = 0.005,
# Outcome = "pgstat",
# data = dataCancer,
# startOffset = 1,
# type = "COX",
# testType = "Wilcox",
# loops = 50,
# fraction = 1)
# # Shut down the graphics device driver
# dev.off()## End(Not run)
Run the code above in your browser using DataLab