| width | R Documentation |
Calculate the mean width of prediction intervals on the validation set.
If window is not NULL, a matrix of the rolling means of interval
width is also returned. If includemedian is TRUE,
the information of the median interval width will be returned.
width(
object,
...,
level = 95,
includemedian = FALSE,
window = NULL,
na.rm = FALSE
)
object |
An object of class |
... |
Additional inputs if |
level |
Target confidence level for prediction intervals. |
includemedian |
If |
window |
If not |
na.rm |
A logical indicating whether |
A list of class "width" with the following components:
width |
Forecast interval width as a multivariate time series, where the |
mean |
Mean interval width across the validation set. |
rollmean |
If |
median |
Median interval width across the validation set. |
rollmedian |
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 width for interval forecasts on validation set
wid_fc <- width(fc, level = 95, window = 50)
str(wid_fc)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.