Learn R Programming

FRESA.CAD (version 2.0.2)

featureAdjustment: Adjust each listed variable to the provided set of covariates

Description

This function fits the candidate variables to the provided model,for each strata, on a control population. If the variance of the residual (the fitted observation minus the real observation) is reduced significantly, then, such residual is used in the resulting data frame. Otherwise, the control mean is subtracted to the observation.

Usage

featureAdjustment(variableList,
	                  baseModel,
	                  strata = "NA",
	                  data,
	                  referenceframe,
	                  type = c("LM", "GLS"),
	                  pvalue = 0.05,
	                  correlationGroup = "ID")

Arguments

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
baseModel
A string of the type "1 + var1 + var2" that defines the model to which variables will be fitted
strata
The name of the column in data that stores the variable that will be used to stratify the model
data
A data frame where all variables are stored in different columns
referenceframe
A data frame similar to data, but with only the control population
type
Fit type: linear fitting ("LM"), or generalized least squares fitting ("GLS")
pvalue
The maximum p-value, associated to the F-test, for the model to be allowed to reduce variability
correlationGroup
The name of the column in data that stores the variable to be used to group the data (only needed if type defined as "GLS")

Value

  • A data frame, where each input observation has been adjusted from data at each strata

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),]
	# Generate a reference frame
	controls <- dataCancer[which(dataCancer$pgstat == 0),]
	# Load a pre-stablished data frame with the names and descriptions of all variables
	data(cancerVarNames)
	# Adjust the g2 variable to age
	adjDataCancer<-featureAdjustment(variableList = cancerVarNames[2,],
	                                 baseModel = "1 + age",
	                                 data = dataCancer,
	                                 referenceframe = controls,
	                                 type = "LM")
	# Shut down the graphics device driver
	dev.off()

Run the code above in your browser using DataLab