| cpi | R Documentation |
This function can calculate the central prediction interval score (IS), overprediction, underprediction, width and coverage of a central prediction interval given observations of univariate variable and quantiles of a predictive distribution for a certain nominal coverage.
cpi(
y,
lower,
upper,
nominal.coverage,
separate = "is",
na.action = na.omit,
aggregate = FALSE,
...
)
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) |
separate |
character; vector with " |
na.action |
function to handle the NA's. Default: |
aggregate |
logical or function for aggregating the single scores, e.g. |
... |
further arguments passed to the |
For a vector y of length n, lower, upper and nominal.coverage should be given as vector
of length n, where the i-th entry of y belongs to the i-th entry of the other vectors. For nominal.coverage
only one value is also sufficient.
The nominal.coverage corresponds to alpha := (100 - nominal.coverage)/100. Consequently lower must provide the alpha/2-quantiles and upper the (1-alpha/2)-quantiles of a predictive distribution.
Internally, nominal.coverage will be transformed to alpha.
The parameter separate allows to choose the output values. "is" is the central prediction interval score, "overprediction" is the overprediction,
"underprediction" is the underprediction, "width" is the central prediction interval width and "coverage" is the central prediction interval coverage.
If an observation lies in a central prediction interval, the output will be 1, otherwise 0 for the parameter "coverage".
A lower IS indicates a better forecast.
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.
Vector or list of score value(s) specified in separate.
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
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))
# cpi calculation
cpi(y = y, lower = lower, upper = upper, nominal.coverage = nominal.coverage,
separate = "is")
cpi(y = y, lower = lower, upper = upper, nominal.coverage = nominal.coverage,
separate = "is", aggregate = mean)
cpi(y = y, lower = lower, upper = upper, nominal.coverage = nominal.coverage,
separate = c("is", "overprediction", "underprediction", "width", "coverage"))
cpi(y = y, lower = lower, upper = upper, nominal.coverage = nominal.coverage,
separate = c("is", "overprediction", "underprediction", "width", "coverage"),
aggregate = mean)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.