Learn R Programming

scoringutils (version 0.1.7.2)

range_plot: Plot Metrics by Range of the Prediction Interval

Description

Visualise the metrics by range, e.g. if you are interested how different interval ranges contribute to the overall interval score, or how sharpness changes by range.

Usage

range_plot(
  scores,
  y = "interval_score",
  x = "model",
  colour = "range",
  facet_formula = NULL,
  scales = "free_y",
  ncol = NULL,
  facet_wrap_or_grid = "facet_wrap",
  xlab = x,
  ylab = y
)

Arguments

scores

A data.frame of scores based on quantile forecasts as produced by eval_forecasts. Note that "range" must be included in the summarise_by argument when running eval_forecasts

y

The variable from the scores you want to show on the y-Axis. This could be something like "interval_score" (the default) or "sharpness"

x

The variable from the scores you want to show on the x-Axis. Usually this will be "model"

colour

Character vector of length one used to determine a variable for colouring dots. The Default is "range".

facet_formula

facetting formula passed down to ggplot. Default is NULL

scales

scales argument that gets passed down to ggplot. Only necessary if you make use of facetting. Default is "free_y"

ncol

Number of columns for facet wrap. Only relevant if facet_formula is given and facet_wrap_or_grid == "facet_wrap"

facet_wrap_or_grid

Use ggplot2's facet_wrap or facet_grid? Anything other than "facet_wrap" will be interpreted as facet_grid. This only takes effect if facet_formula is not NULL

xlab

Label for the x-axis. Default is the variable name on the x-axis

ylab

Label for the y-axis. Default is "WIS contributions"

Value

A ggplot2 object showing a contributions from the three components of the weighted interval score

Examples

Run this code
# NOT RUN {
scores <- scoringutils::eval_forecasts(scoringutils::quantile_example_data,
                                        summarise_by = c("model", "value_desc", "range"))

scores <- scoringutils::eval_forecasts(scoringutils::range_example_data_long,
                                        summarise_by = c("model", "value_desc", "range"))
scoringutils::range_plot(scores, x = "model", facet_formula = ~ value_desc)

# visualise sharpness instead of interval score
scoringutils::range_plot(scores, y = "sharpness", x = "model",
                          facet_formula =  ~value_desc)

# we saw above that sharpness values crossed. Let's look at the unweighted WIS
scores <- scoringutils::eval_forecasts(scoringutils::range_example_data_long,
                                        interval_score_arguments = list(weigh = FALSE),
                                        summarise_by = c("model", "value_desc", "range"))
scoringutils::range_plot(scores, y = "sharpness", x = "model",
                          facet_formula =  ~value_desc)
# }

Run the code above in your browser using DataLab