| coverage | R Documentation |
Calculate the mean coverage and the ifinn matrix for prediction intervals on
validation set. If window is not NULL, a matrix of the rolling
means of interval forecast coverage is also returned.
coverage(object, ..., level = 95, window = NULL, na.rm = FALSE)
object |
An object of class |
... |
Additional inputs if |
level |
Target confidence level for prediction intervals. |
window |
If not |
na.rm |
A logical indicating whether |
A list of class "coverage" with the following components:
mean |
Mean coverage across the validation set. |
ifinn |
A indicator matrix as a multivariate time series, where the |
rollmean |
If |
# Simulate time series from an AR(2) model
library(forecast)
series <- arima.sim(n = 200, list(ar = c(0.8, -0.5)), sd = sqrt(1))
# Cross-validation forecasting with a rolling window
far2 <- function(x, h, level) {
Arima(x, order = c(2, 0, 0)) |>
forecast(h = h, level)
}
fc <- cvforecast(series, forecastfun = far2, h = 3, level = 95,
forward = TRUE, initial = 1, window = 50)
# Mean and rolling mean coverage for interval forecasts on validation set
cov_fc <- coverage(fc, level = 95, window = 50)
str(cov_fc)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.