Learn R Programming

FRESA.CAD (version 2.0.2)

updateModel: Update the IDI/NRI-based model using new data or new threshold values

Description

This function will take the frequency-ranked set of variables and will generate a new model with terms that meet either the integrated discrimination improvement (IDI), or the net reclassification improvement (NRI), threshold criteria.

Usage

updateModel(Outcome,
	            covariates = "1",
	            pvalue = c(0.05, 0.02),
	            VarFrequencyTable, 
	            variableList,
	            data,
	            type = c("LM", "LOGIT", "COX"), 
	            lastTopVariable = 0,
	            timeOutcome = "Time",
	            selectionType = c("zIDI","zNRI"),
	            numberOfModels = 3,
	            interaction = 1,
	            maxTrainModelSize = 0)

Arguments

Outcome
The name of the column in data that stores the variable to be predicted by the model
covariates
A string of the type "1 + var1 + var2" that defines which variables will always be included in the models (as covariates)
pvalue
The maximum p-value, associated to either IDI or NRI, allowed for a term in the model
VarFrequencyTable
An array with the ranked frequencies of the features, (e.g. the ranked.var value returned by the ReclassificationFRESA.Model function)
variableList
A data frame with two columns. The first one must have the names of the candidate variables and the other one the description of such variables
data
A data frame where all variables are stored in different columns
type
Fit type: Logistic ("LOGIT"), linear ("LM"), or Cox proportional hazards ("COX")
lastTopVariable
The maximum number of variables to be tested
timeOutcome
The name of the column in data that stores the time to event (needed only for a Cox proportional hazards regression model fitting)
selectionType
The type of index to be evaluated by the improveProb function (Hmisc package): z-score of IDI or of NRI
numberOfModels
The number of models to be extracted based on the ranked variables
interaction
Set to either 1 for first order models, or to 2 for second order models
maxTrainModelSize
Maximum number of terms that can be included in the model

Value

  • final.modelAn object of class lm, glm, or coxph containing the final model
  • var.namesA vector with the names of the features that were included in the final model
  • formulaAn object of class formula with the formula used to fit the final model
  • z.selectionTypeA vector in which each term represents the z-score of the index defined in selectionType obtained with the full model and the model without one term
  • loopsThe number of loops it took for the model to stabilize
  • formula.listA list containing objects of class formula with the formulas used to fit the models found at each cycle

See Also

updateNeRIModel

Examples

Run this code
# 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:
	# - 10 bootstrap loops
	# - zIDI as the feature inclusion criterion
	cancerModel <- ReclassificationFRESA.Model(loops = 10,
	                                           Outcome = "pgstat",
	                                           variableList = cancerVarNames,
	                                           data = dataCancer,
	                                           type = "COX",
	                                           timeOutcome = "pgtime",
	                                           selectionType = "zIDI")
	# Update the model, adding first order interactions
	uCancerModel <- updateModel(Outcome = "pgstat",
	                            VarFrequencyTable = cancerModel$ranked.var,
	                            variableList = cancerVarNames,
	                            data = dataCancer,
	                            type = "COX",
	                            timeOutcome = "pgtime",
	                            interaction = 2)
	# Shut down the graphics device driver
	dev.off()

Run the code above in your browser using DataLab