| update.cpforecast | R Documentation |
Update conformal prediction intervals and other information by applying the
cvforecast and conformal functions. Only the newly added time
steps are computed: the prediction intervals produced earlier are carried
over unchanged.
## S3 method for class 'cpforecast'
update(object, new_data, forecastfun, new_xreg = NULL, ...)
object |
An object of class |
new_data |
A non-empty numeric 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 the newly appended data
and the re-computed cross-validation forecasts and conformal prediction
intervals.
cvforecast and conformal, which
produce the object to be updated.
# Simulate time series from an AR(2) model
library(forecast)
set.seed(1)
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, window = 50)
# Classical conformal prediction with equal weights
scpfc <- conformal(fc, method = "scp", 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.