Learn R Programming

FRESA.CAD (version 2.2.0)

plotModels.ROC: Plot test ROC curves of each cross-validation model

Description

This function plots test ROC curves of each model found in the cross validation process. It will also aggregate the models into a single prediction performance, plotting the resulting ROC curve (models coherence). Furthermore, it will plot the mean sensitivity for a given set of specificities.

Usage

plotModels.ROC(modelPredictions, number.of.models=0, specificities=c(0.975,0.95,0.90,0.80,0.70,0.60,0.50,0.40,0.30,0.20,0.10,0.05), theCVfolds=1, predictor="Prediction", ...)

Arguments

modelPredictions
A data frame returned by the crossValidationFeatureSelection_Bin function, either the Models.testPrediction, the FullBWiMS.testPrediction, the Models.CVtestPredictions, the TestRetrained.blindPredictions, the KNN.testPrediction, or the LASSO.testPredictions value
number.of.models
The maximum number of models to plot
specificities
Vector containing the specificities at which the ROC sensitivities will be calculated
theCVfolds
the number of folds performed in a Cross-validation experiment
predictor
the name of the column to be ploted
...
Additional parameters for the roc function (pROC package)

Value

ROC.AUCs
A vector with the AUC of each ROC
mean.sensitivities
A vector with the mean sensitivity at the specificities given by specificities
model.sensitivities
A matrix where each row represents the sensitivitiy at the specificities given by specificities for a different ROC
specificities
The specificities used to calculate the sensitivities
senAUC
The AUC of the ROC curve that resulted from using mean.sensitivities
predictionTable
The confusion matrix between the outcome and the ensembled prediction
ensemblePrediction
The ensembled (median prediction) of the repeated predictions

Examples

Run this code
	## 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)
# 	# Rank the variables:
# 	# - Analyzing the raw data
# 	# - According to the zIDI
# 	rankedDataCancer <- univariateRankVariables(variableList = cancerVarNames,
# 	                                            formula = "Surv(pgtime, pgstat) ~ 1",
# 	                                            Outcome = "pgstat",
# 	                                            data = dataCancer,
# 	                                            categorizationType = "Raw",
# 	                                            type = "COX",
# 	                                            rankingTest = "zIDI",
# 	                                            description = "Description")
# 	# Get a Cox proportional hazards model using:
# 	# - The top 7 ranked variables
# 	# - 10 bootstrap loops in the feature selection procedure
# 	# - The zIDI as the feature inclusion criterion
# 	# - 5 bootstrap loops in the backward elimination procedure
# 	# - A 5-fold cross-validation in the feature selection, 
# 	#            update, and backward elimination procedures
# 	# - A 10-fold cross-validation in the model validation procedure
# 	# - First order interactions in the update procedure
# 	cancerModel <- crossValidationFeatureSelection_Bin(size = 7,
# 	                                               loops = 10,
# 	                                               Outcome = "pgstat",
# 	                                               timeOutcome = "pgtime",
# 	                                               variableList = rankedDataCancer,
# 	                                               data = dataCancer,
# 	                                               type = "COX",
# 	                                               selectionType = "zIDI",
# 	                                               elimination.bootstrap.steps = 5,
# 	                                               trainRepetition = 5,
# 	                                               CVfolds = 10,
# 	                                               interaction = c(1,2))
# 	# Plot the results of the blind test set predictions made at each 
# 	# fold of the cross-validation
# 	cancerModelPlot <- plotModels.ROC(cancerModel$Models.testPrediction)
# 	# Shut down the graphics device driver
# 	dev.off()## End(Not run)

Run the code above in your browser using DataLab