cpi.plot: Central Prediction Intervals Plot

View source: R/cpi.plot.R

cpi.plotR Documentation

Central Prediction Intervals Plot

Description

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.

Usage

cpi.plot(
  x,
  y,
  lower,
  upper,
  nominal.coverage,
  x.lab = "",
  y.lab = "",
  title = paste0(nominal.coverage, "% Central Prediction Interval"),
  info = FALSE
)

Arguments

x

evaluation points of class "Date", "numeric" or "integer"

y

vector of observations

lower

vector with the lower quantiles (depending on nominal.coverage; see details)

upper

vector with the upper quantiles (depending on nominal.coverage; see details)

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: "nominal.coverage% Central Prediction Interval"

info

logical; if TRUE the mean central prediction interval width and coverage are calculated for the plot (see details); if FALSE the mean central prediction interval width and coverage are not calculated; default: FALSE

Details

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.

Value

ggplot object with a plot of the central prediction intervals.

Author(s)

David Jobst

References

Gneiting, T. and Raftery, A. (2007). Strictly Proper Scoring Rules, Prediction,and Estimation. Journal of the American Statistical Association, 102, 359-378.

Examples

# 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)


jobstdavid/eppverification documentation built on May 13, 2024, 5:20 p.m.