mlf: Conformalized Forecasting using Machine Leaning models

View source: R/ml.R

mlfR Documentation

Conformalized Forecasting using Machine Leaning models

Description

Conformalized Forecasting using Machine Leaning models

Usage

mlf(
  y,
  h = 5,
  level = 95,
  lags = 15L,
  fit_func = ahead::ridge,
  predict_func = predict,
  coeffs = NULL,
  type_pi = c("kde", "surrogate", "bootstrap"),
  B = 250L,
  agg = c("mean", "median"),
  seed = 123,
  ...
)

Arguments

y

A numeric vector or time series of class ts

h

Forecasting horizon

level

Confidence level for prediction intervals

lags

Number of lags of the input time series considered in the regression

fit_func

Fitting function (Statistical/ML model). Default is Ridge regression.

predict_func

Prediction function (Statistical/ML model)

coeffs

Coefficients of the fitted model. If provided, a linear combination with the coefficients is used to compute the prediction.

type_pi

Type of prediction interval

B

Number of bootstrap replications or number of simulations

agg

"mean" or "median" (aggregation method)

...

additional parameters passed to the fitting function fit_func

Examples


res <- ahead::mlf(USAccDeaths, h=10L, lags=15L, type_pi="surrogate", B=250L)
plot(res)

res <- ahead::mlf(USAccDeaths, fit_func = glmnet::cv.glmnet, h=15L, lags=15L, 
type_pi="kde", B=250L) 
plot(res)

(res <- ahead::mlf(USAccDeaths, fit_func = e1071::svm, h=15L, lags=15L, 
type_pi="kde", B=250L)) 
plot(res)


Techtonique/ahead documentation built on April 14, 2025, 12:51 p.m.