The R package conformalForecast provides methods and tools for performing multistep-ahead time series forecasting using conformal prediction methods including classical conformal prediction, adaptive conformal prediction, conformal PID control, and autocorrelated multistep-ahead conformal prediction.
You can install the development version of conformalForecast from GitHub with:
# install.packages("remotes")
::install_github("xqnwang/conformalForecast") remotes
You can also get the official release version from CRAN:
install.packages("conformalForecast")
This is a basic example which shows you how to perform a classical conformal prediction method:
library(conformalForecast)
library(forecast)
# Simulate time series from an AR(2) model
<- arima.sim(n = 1000, list(ar = c(0.8, -0.5)), sd = sqrt(1))
series
# Time series cross-validation
<- function(x, h, level) {
far2 Arima(x, order = c(2, 0, 0)) |>
forecast(h = h, level)
}<- cvforecast(series, forecastfun = far2, h = 3, level = c(80, 95),
fc forward = TRUE, initial = 1, window = 100)
# Classical conformal prediction
<- scp(fc, symmetric = FALSE, ncal = 100, rolling = TRUE)
scpfc
# Interval forecast accuracy
accuracy(scpfc, byhorizon = TRUE)
# Mean coverage
coverage(scpfc, window = 500, level = 95)
# Mean and median interval width
width(scpfc, window = 500, level = 95, includemedian = TRUE)
This package is free and open source software, licensed under GPL-3.