| plot_density_forecast | R Documentation |
Generates a kernel density plot of a predictive distribution,
highlighting the point forecast and a symmetric credible interval at a
specified level. The predictive distribution can be constructed by treating
the cross-sectional spread of model forecasts at a given period as a proxy
for forecast uncertainty (see compute_crps for the centring
convention).
plot_density_forecast(
full_distribution,
point_forecast,
title = "Density Forecast",
ci_level = 0.9
)
full_distribution |
Numeric vector of forecast samples drawn from the
predictive distribution (e.g., forecasts from all models at one time
period, optionally centred and shifted as in |
point_forecast |
Single numeric value: the point forecast to highlight
(e.g., the mean or median of |
title |
Character string for the plot title. Default is
|
ci_level |
Numeric confidence interval level strictly between 0 and 1.
Default is 0.90, producing lower and upper quantiles at
|
To build a pseudo-predictive distribution from the metals dataset,
centre the cross-sectional model forecasts at period t around their
mean, following the same convention used in compute_crps:
dist_t <- forecasts[t, ] - forecasts[t, k] + mean(forecasts[t, ]).
This preserves cross-sectional spread while recentring on the cross-sectional
mean rather than on model k's own point forecast.
A ggplot object. The plot shows a kernel density curve
(blue fill), a red dashed vertical line at point_forecast, and
orange dotted vertical lines at the lower and upper quantiles of the
credible interval. The subtitle reports the numeric bounds of the interval.
compute_crps, run_comprehensive_erc_analysis'
data(metals)
t <- 100
K <- ncol(metals) - 1
dist_t <- as.numeric(metals[t, 1:K]) - metals[t, 7] +
mean(as.numeric(metals[t, 1:K]))
pt_fcst <- mean(as.numeric(metals[t, 1:K]))
plot_density_forecast(dist_t, pt_fcst,
title = "Predictive Density at t = 100",
ci_level = 0.90)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.