| update.cpforecast | R Documentation |
Update conformal prediction intervals and other information by applying the
cvforecast and conformal functions.
## S3 method for class 'cpforecast'
update(object, new_data, forecastfun, new_xreg = NULL, ...)
object |
An object of class |
new_data |
A vector of newly available data. |
forecastfun |
Function to return an object of class |
new_xreg |
Newly available exogenous predictor variables passed to
|
... |
Other arguments are passed to |
A refreshed object of class "cpforecast" with updated fields (e.g.,
x, MEAN, ERROR, LOWER, UPPER, and any
method-specific components), reflecting newly appended data and re-computed
cross-validation forecasts and conformal prediction intervals.
# 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
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)
# Classical conformal prediction with equal weights
scpfc <- conformal(fc, method = "scp", symmetric = FALSE, ncal = 50, rolling = TRUE)
# Update conformal prediction using newly available data
scpfc_update <- update(scpfc, forecastfun = far2, new_data = c(1.5, 0.8, 2.3))
print(scpfc_update)
summary(scpfc_update)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.