Do the ROC analysis (roc_analysis) for each column of x.
# S3 method for manyroc_result print(x, ..., show_all = FALSE, perf_digits = 2, fmt = "%.3g") roc_manyroc(x, gr = NULL, optimize_by = "bac", ...) # S3 method for matrix roc_manyroc(x, gr = NULL, optimize_by = "bac", ..., gr_sep = " vs. ") # S3 method for numeric roc_manyroc(x, gr = NULL, optimize_by = "bac", ...) # S3 method for data.frame roc_manyroc(x, gr = NULL, optimize_by = "bac", ...) # S3 method for hyperSpec roc_manyroc(x, gr = NULL, optimize_by = "bac", ...)
| x | A numeric matrix, a data frame, a |
|---|---|
| ... | Arguments passed for further methods. |
| show_all | ( |
| perf_digits | ( |
| fmt | ( |
| gr | Either a string (scalar, |
| optimize_by | (
|
| gr_sep | Group separator used to paste the names of groups. Default is
|
Object of classes manyroc_result and data.frame with
columns:
compared_groups Names of compared groups (separated by
gr_sep with default value " vs. ");
feature names of numeric features used in analysis;
median_neg median value of negatives group;
cutoff for optimal threshold/cut-off values and
corresponding performance measures;
median_pos median value positives group;
TP number of true positives;
FN number of false negatives;
FP number of false positives;
TN number of true negatives;
sens sensitivity (true positive rate, recall);
spec specificity (true negative rate);
PPV positive predictive value (precision);
NPV negative predictive value;
BAC balanced accuracy;
Youden Youden’s J index;
Kappa Cohen's kappa;
AUC area under the ROC curve;
Consider ordering of factor gr levels before the analysis, as the
first level will always be treated as negative and the last as positive.
E.g., if we have factor with 3 levels in this particular order
"A", "B", "C", then "A" will always be negative, "C" always positive and
"B" positive, when compared to "A" and negative, when compared to "C".
The same principle applies if there are more than 3 levels.
This is important determining what specificity and sensitivity, etc., means
in the context of group names: if positive is "A" then sensitivity
will be related to group "A", but if "A" is negative, then specificity
will be related to this group, and sensitivity to the other group.
For spectroscopic data: compare spectra of each pair of indicated groups at each wavelength.
Vilmantas Gegzna
library(manyROC) # --- For numeric vectors objects --- data(PlantGrowth) roc_manyroc(x = PlantGrowth$weight, gr = PlantGrowth$group)#> compared_groups feature median_neg cutoff median_pos tp fn fp tn sens spec #> 1 ctrl vs. trt1 1 5.15 4.37 4.55 5 5 1 9 0.50 0.90 #> 2 ctrl vs. trt2 1 5.15 5.22 5.44 8 2 3 7 0.80 0.70 #> 3 trt1 vs. trt2 1 4.55 4.9 5.44 10 0 2 8 1.00 0.80 #> ppv npv bac youden kappa auc #> 1 0.83 0.64 0.70 0.40 0.40 0.67 #> 2 0.73 0.78 0.75 0.50 0.50 0.75 #> 3 0.83 1.00 0.90 0.80 0.80 0.84#> compared_groups feature median_neg cutoff median_pos tp fn fp tn sens #> 1 Quebec vs. Mississippi conc 350 200 350 18 24 18 24 0.43 #> 2 Quebec vs. Mississippi uptake 37.2 32.3 19.3 41 1 13 29 0.98 #> spec ppv npv bac youden kappa auc #> 1 0.57 0.50 0.50 0.50 0.00 0.00 0.50 #> 2 0.69 0.76 0.97 0.83 0.67 0.67 0.84#> compared_groups feature median_neg cutoff median_pos tp fn fp tn sens #> 1 A vs. B 1 4 5.5 7.5 6 2 1 7 0.75 #> 2 A vs. C 1 4 12.5 16.5 7 1 0 8 0.88 #> 3 A vs. D 1 4 16 32 8 0 0 8 1.00 #> 4 A vs. E 1 4 25.5 53 8 0 0 8 1.00 #> ... ... ... ... ... ... ... ... ... ... ... #> 25 E vs. H 1 53 65 81 8 0 2 6 1.00 #> 26 F vs. G 1 70 70 72 6 2 4 4 0.75 #> 27 F vs. H 1 70 71.5 81 7 1 3 5 0.88 #> 28 G vs. H 1 72 80.5 81 5 3 1 7 0.62 #> #> spec ppv npv bac youden kappa auc #> 1 0.88 0.86 0.78 0.81 0.62 0.62 0.80 #> 2 1.00 1.00 0.89 0.94 0.88 0.88 0.98 #> 3 1.00 1.00 1.00 1.00 1.00 1.00 1.00 #> 4 1.00 1.00 1.00 1.00 1.00 1.00 1.00 #> ... ... ... ... ... ... ... ... #> 25 0.75 0.80 1.00 0.88 0.75 0.75 0.81 #> 26 0.50 0.60 0.67 0.62 0.25 0.25 0.55 #> 27 0.62 0.70 0.83 0.75 0.50 0.50 0.70 #> 28 0.88 0.83 0.70 0.75 0.50 0.50 0.75 #>#> hyperSpec object #> 150 spectra #> 3 data columns #> 501 data points / spectrum #> wavelength: lambda/nm [integer] 300 301 ... 800 #> data: (150 rows x 3 columns) #> 1. gr: [factor] B B ... A #> 2. class: [factor] N l ... S1 #> 3. spc: I / a.u. [matrix, array501] 159.8996 139.9296 ... 12.11558roc_manyroc(fluorescence[, , 500 ~ 502], fluorescence$gr)#> compared_groups feature median_neg cutoff median_pos tp fn fp tn sens spec #> 1 A vs. B 1 338 335 333 35 20 24 28 0.64 0.54 #> 2 A vs. B 2 335 328 327 29 26 19 33 0.53 0.63 #> 3 A vs. B 3 335 332 329 36 19 24 28 0.65 0.54 #> 4 A vs. C 1 338 329 334 21 22 20 32 0.49 0.62 #> 5 A vs. C 2 335 329 334 21 22 20 32 0.49 0.62 #> 6 A vs. C 3 335 340 340 22 21 22 30 0.51 0.58 #> 7 B vs. C 1 333 343 334 21 22 15 40 0.49 0.73 #> 8 B vs. C 2 327 344 334 21 22 15 40 0.49 0.73 #> 9 B vs. C 3 329 339 340 22 21 16 39 0.51 0.71 #> ppv npv bac youden kappa auc #> 1 0.59 0.58 0.59 0.17 0.18 0.57 #> 2 0.60 0.56 0.58 0.16 0.16 0.56 #> 3 0.60 0.60 0.60 0.19 0.19 0.56 #> 4 0.51 0.59 0.55 0.10 0.10 0.50 #> 5 0.51 0.59 0.55 0.10 0.10 0.49 #> 6 0.50 0.59 0.54 0.09 0.09 0.51 #> 7 0.58 0.65 0.61 0.22 0.22 0.57 #> 8 0.58 0.65 0.61 0.22 0.22 0.57 #> 9 0.58 0.65 0.61 0.22 0.22 0.56