group.auc.test {ROCpsych} | R Documentation |
Function to compare AUC across all consecutive categories of an ordinal scale
Description
This function computes commonly used classification statistics of a confusion matrix and compares the area under the curve (AUC) across all consecutive categories of an ordinal variable. The function of roc.test () from the pROC package (https://cran.r-project.org/package=pROC) is used for AUC comparison.
Usage
group.auc.test(outcome,predictor,
groups, cut.off='max.Youden',BR=1)
Arguments
outcome |
The outcome variable indicating the status in the form of a data frame or matrix. This variable is typically coded as 0 (positive) and 1 (negative). |
predictor |
A numerical vector of scores used to predict the status of the outcome. This variable should be of the same length as the outcome variable (i.e., two variables are from the same data set and also of the same number of data rows). |
groups |
A data frame that contains all created indicator variables using the function group.to.vars () in this package. |
cut.off |
Specification of the criterion used to select the optimal cut score. Three options available: (1) 'max.Youden' returns the cut score that maximizes the Youden Index (the default); (2) 'max.sen' returns the cut score that maximizes the sensitivity; and (3) 'max.spe' returns the cut score that maximizes the specificity. |
BR |
Base rates or known prevalence. Multiple values can be specified simultaneously. By default BR=1. |
Value
A list of two objects: (1) descriptive and classification statistics, and (2) results of the AUC comparison for each pair of the consecutive categories.
Summary.Stats |
Summary and classification statistics for all participants and
all the consecutive groups. The first row is the results of the entire sample and has a row name of "All",
followed by results for each pair of the groups specified by group.to.vars (). For example,
if the first indicator of age is age.40, then the second row of results will have the row name of "age.40" and
includes results for participants with age at or below 40, the third row will have the row name of
"age.40.1" and includes results for those with age beyond 40. |
AUC.test |
Results of the AUC comparison for each pair of the consecutive categories. |
Examples
#read the example data
data(ROC.data.ex)
#create new binary variables for the ordinal variable
data.new.age<-group.to.vars(ROC.data.ex,
ROC.data.ex$age,
root.name='age')
#run the function
result.age<-group.auc.test(ROC.data.ex$outcome,ROC.data.ex$predictor,
groups=data.new.age[,5:ncol(data.new.age)],
cut.off='max.Youden', BR=1)
#obtain results
result.age$Summary.Stats
result.age$AUC.test