R interface to ForecastBaselines.jl
An R package providing access to 10 baseline forecasting models from the Julia ForecastBaselines.jl library, with uncertainty quantification and seamless integration with the scoringutils package and hubverse ecosystem.
install.packages("JuliaCall")
# Install from GitHub
remotes::install_github("epiforecasts/forecastbaselines")After installation, initialize Julia and load ForecastBaselines.jl:
library(forecastbaselines)
# Initialize Julia and install/load ForecastBaselines.jl
setup_ForecastBaselines()This only needs to be done once per R session.
library(scoringutils) # for scoring
# Your time series data
data <- c(1.2, 2.3, 3.1, 2.8, 3.5, 4.2, 3.9, 4.5, 4.1, 4.8)
# 1. Create and fit a model
model <- ARMAModel(p = 1, q = 1)
fitted <- fit_baseline(data, model)
# 2. Generate forecasts with prediction intervals
fc <- forecast(
fitted,
interval_method = EmpiricalInterval(n_trajectories = 1000),
horizon = 1:5,
levels = c(0.50, 0.95),
model_name = "ARMA(1,1)"
)
# 3. Evaluate with true values
truth <- c(5.0, 5.2, 5.4, 5.1, 5.3)
fc_with_truth <- add_truth(fc, truth)
# 4. Score the forecast
fc_point <- as_forecast_point(fc_with_truth)
scores <- score(fc_point)
scores_summary <- summarise_scores(scores, by = "model")
scores_summary[, c("model", "ae_point", "se_point")]
#> model ae_point se_point
#> <char> <num> <num>
#> 1: ARMA(1,1) 0.2368795 0.07611188For detailed guides and examples:
vignette("forecastbaselines") - Complete introduction with examplesvignette("forecast-models") - Detailed guide to all 10 modelsvignette("transformations") - Working with data transformationsSome of the models in forecastbaselines are also available through other R packages. For time series forecasting in R, consider:
forecastbaselines focuses specifically on baseline models for forecast evaluation and integrates with the scoringutils/hubverse ecosystem.
If you use this package in your research, please cite the software and the associated preprint:
Software:
@software{forecastbaselinesr,
title = {forecastbaselines: R Interface to ForecastBaselines.jl},
author = {Stapper, Manuel and Funk, Sebastian},
year = {2025},
url = {https://github.com/epiforecasts/forecastbaselines}
}Preprint:
For bugs and feature requests:
All contributions to this project are gratefully acknowledged using the allcontributors package following the allcontributors specification. Contributions of any kind are welcome!