Learn R Programming

scoringutils (version 0.1.4)

plot_predictions: Plot Predictions vs True Values

Description

Make a plot of observed and predicted values

Usage

plot_predictions(
  data,
  x = "date",
  add_truth_data = NULL,
  range = c(0, 50, 90),
  facet_formula = NULL,
  facet_wrap_or_grid = "facet_wrap",
  scales = "free_y",
  xlab = x,
  ylab = "True and predicted values"
)

Arguments

data

a data.frame that follows the same specifications outlined in eval_forecasts. The data.frame needs to have columns called "true_value", "prediction" and then either a column called sample, or one called "quantile" or two columns called "range" and "boundary".

x

character vector of length one that denotes the name of the variable on the x-axis. Usually, this will be "date", but it can be anything else.

add_truth_data

additional truth data, e.g. past values for which no predictions are available. This should be a data.frame with a column called "true_value" and another column corresponding to the x variable selected for the plot

range

numeric vector indicating the interval ranges to plot. If 0 is included in range, the median prediction will be shown.

facet_formula

formula for facetting in ggplot. If this is NULL (the default), no facetting will take place

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

scales

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

xlab

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

ylab

Label for the y-axis. Default is "True and predicted values"

Value

ggplot object with a plot of true vs predicted values

Examples

Run this code
# NOT RUN {
example1 <- scoringutils::continuous_example_data
example2 <- scoringutils::quantile_example_data_long

scoringutils::plot_predictions(example1, x = "id",
                               facet_formula = ~ horizon)
scoringutils::plot_predictions(example2, x = "id",
                               facet_formula = ~ horizon)
# }

Run the code above in your browser using DataLab