| plot_cumulative_loss | R Documentation |
Generates a time-series plot of cumulative squared error (MSE)
loss differences between each competing forecast and the benchmark. A positive
value at time t means the competing forecast has accumulated lower squared
errors than the benchmark up to that point (i.e., the forecast is outperforming
the benchmark cumulatively).
plot_cumulative_loss(data_matrix, benchmark_col = ncol(data_matrix))
data_matrix |
Matrix or data frame of dimension |
benchmark_col |
Index or name of the benchmark column. Defaults to the last column. |
The cumulative loss difference for forecast k at time t is:
\text{CLD}_{k,t} =
\sum_{s=1}^{t} \left( e_{\text{bench},s}^2 - e_{k,s}^2 \right)
where e_{k,s} = y_s - \hat{y}_{k,s} is the forecast error of forecast
k at period s. The function squares the values in
data_matrix directly, so pre-computed forecast errors
(not raw forecasts) must be passed for the result to represent cumulative
MSE differences.
A positive \text{CLD}_{k,t} means forecast k has accumulated lower
squared errors than the benchmark up to period t. A negative value
means the benchmark has been more accurate up to that point.
A ggplot object. The y-axis shows the cumulative MSE
difference; forecasts above zero at the right edge have outperformed the
benchmark over the full evaluation window. The top 2 and bottom 2 forecasts
(by final cumulative loss difference) are labelled directly on the plot.
white_reality_check,
plot_performance_metrics
data(metals)
P <- nrow(metals)
K_total <- ncol(metals)
realized <- c(metals[-1, K_total], metals[P, K_total])
errors <- sweep(as.matrix(metals), 1, realized, "-")
p <- plot_cumulative_loss(errors, benchmark_col = K_total)
print(p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.