cpi.plot | R Documentation |
This function plots the central prediction intervals given evaluation points, observations of an univariate variable and quantiles of a predictive distribution for a certain interval range.
cpi.plot(
x,
y,
lower,
upper,
nominal.coverage,
x.lab = "",
y.lab = "",
title = paste0(nominal.coverage, "% Central Prediction Interval"),
info = FALSE
)
x |
evaluation points of class " |
y |
vector of observations |
lower |
vector with the lower quantiles (depending on |
upper |
vector with the upper quantiles (depending on |
nominal.coverage |
numeric; nominal coverage in % (see details) |
x.lab |
character; label of x-axis; default: "" |
y.lab |
character; label of y-axis; default: "" |
title |
character; title of the plot; default: " |
info |
logical; if |
For x
of length n, y
, lower
and upper
should be given as vector
of length n, where the i-th entry of x
belongs to the i-th entry of the other vectors.
NA's are omitted.
A lower central prediction interval width indicates a sharper forecast.
A score of the central prediction interval coverage close to nominal.coverage
indicates a more calibrated forecast.
A central prediction interval coverage score of nominal.coverage
is optimal and indicates a calibrated forecast.
ggplot object with a plot of the central prediction intervals.
David Jobst
Gneiting, T. and Raftery, A. (2007). Strictly Proper Scoring Rules, Prediction,and Estimation. Journal of the American Statistical Association, 102, 359-378.
# simulated data
n <- 30
x1 <- 1:n
x2 <- seq(Sys.Date(), by = "day", length.out = n)
y <- rnorm(n, mean = 1:n)
nominal.coverage <- 90
alpha <- (100-nominal.coverage)/100
lower <- qnorm(alpha/2, rnorm(n, mean = 1:n))
upper <- qnorm((1-alpha/2), rnorm(n, mean = 1:n))
x.lab <- "Date"
y.lab <- "Value"
title <- "Central Prediction Interval"
# cpi.plot plot
cpi.plot(x = x1, y = y, lower = lower, upper = upper,
nominal.coverage = nominal.coverage)
cpi.plot(x = x2, y = y, lower = lower, upper = upper,
nominal.coverage = nominal.coverage, x.lab = x.lab, y.lab = y.lab,
title = title, info = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.