Learn R Programming

conformalForecast (version 0.1.0)

conformal: Conformal prediction

Description

This function allows you to specify the method used to perform conformal prediction.

Usage

conformal(object, ...)

# S3 method for cvforecast conformal(object, method = c("scp", "acp", "pid", "acmcp"), ...)

Value

An object whose class depends on the method invoked.

Arguments

object

An object of class "cvforecast". It must have an argument x for original univariate time series, an argument MEAN for point forecasts and ERROR for forecast errors on validation set. See the results of a call to cvforecast.

...

Additional arguments to be passed to the selected conformal method.

method

A character string specifying the conformal method to be applied. Possible options include "scp" (scp), "acp"(acp), "pid"(pid), and "acmcp"(acmcp).

See Also

scp, acp, pid, and acmcp

Examples

Run this code
# 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)
summary(scpfc)

# ACP with asymmetric nonconformity scores and rolling calibration sets
acpfc <- conformal(fc, method = "acp", symmetric = FALSE, gamma = 0.005,
                   ncal = 50, rolling = TRUE)
summary(acpfc)

Run the code above in your browser using DataLab