ROC_curve {SeaVal} | R Documentation |
ROC curve for tercile forecasts
Description
Creates ROC curves from a data table containing tercile forecasts. It wraps roc_curve_vec
.
By default, 4 ROC-curves are drawn, one for each the prediction of above-, normal- and below-values, plus one for all forecasts together.
You can provide a 'by' argument to obtain separate ROC-curves for different values of the by-columns. E.g., when your data table contains
a column named 'season', you can set by = 'season'. Then, the function will output a list of 16 ROC-curvess, 4 for each season.
Usage
ROC_curve(
dt,
f = c("below", "normal", "above"),
o = tc_cols(dt),
by = NULL,
pool = setdiff(dimvars(dt), by),
interpolate = TRUE,
dim.check = TRUE
)
Arguments
dt |
Data table containing tercile forecasts |
f |
column names of the prediction columns |
o |
column name of the observation column |
by |
column names of grouping variables. Default is to not group. |
pool |
column names of pooling variables (used for the dimension check). Default is all dimvars. |
interpolate |
Logical. If TRUE, the curve connects the dots making up the ROC curve (which looks nicer), if not a step function is drawn (which is closer to the mathematical definition of the ROC curve). |
dim.check |
Logical. If TRUE, the function checks whether the columns in by and pool span the entire data table. |
Value
A list of gg objects which can be plotted by ggpubr::ggarrange
(for example)
Examples
dt = data.table(below = c(0.5,0.3,0),
normal = c(0.3,0.3,0.7),
above = c(0.2,0.4,0.3),
tc_cat = c(-1,0,0),
lon = 1:3)
print(dt)
pp = ROC_curve(dt)
if(interactive()) plot(pp)