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.
- Baseline and benchmark models for forecast evaluation
- Multiple uncertainty quantification methods (bootstrap, analytical, conformal)
- Seamless integration with scoringutils for proper scoring rules
- Data transformations with automatic back-transformation
- Julia (>= 1.9): Download from julialang.org
- R (>= 3.5.0)
- JuliaCall R package:
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.07611188- ConstantModel: Naive forecast using last observed value
- MarginalModel: Forecasts based on empirical marginal distribution
- KDEModel: Kernel density estimation
- LSDModel: Last Similar Dates method (seasonal patterns)
- OLSModel: Ordinary least squares with polynomial trends
- IDSModel: Increase-Decrease-Stable trend detection
- STLModel: Seasonal-Trend decomposition using Loess
- ARMAModel: Autoregressive Moving Average
- INARCHModel: Integer-valued ARCH for count data
- ETSModel: Error-Trend-Season exponential smoothing (all 30 variants)
For detailed guides and examples:
vignette("forecastbaselines")- Complete introduction with examplesvignette("forecast-models")- Detailed guide to all 10 modelsvignette("transformations")- Working with data transformations
Some of the models in {forecastbaselines} are also available through
other R packages. For time series forecasting in R, consider:
- fable - A complete forecasting framework in the tidyverts ecosystem with ARIMA, ETS, and many other models
- forecast - The classic R forecasting package with auto.arima, ets, and many other methods
- prophet - Facebook’s forecasting package for time series with strong seasonal patterns
- modeltime - A tidymodels framework for time series forecasting
{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:
@article{stapper2025baseline,
title = {Mind the Baseline: The Hidden Impact of Reference Model Selection on Forecast Assessment},
author = {Stapper, Manuel and Funk, Sebastian},
year = {2025},
doi = {10.1101/2025.08.01.25332807},
url = {https://doi.org/10.1101/2025.08.01.25332807}
}
MIT License - see LICENSE file for details
For bugs and feature requests:
- R package issues: GitHub Issues
- Julia package issues: ForecastBaselines.jl Issues
All contributions to this project are gratefully acknowledged using the
allcontributors package
following the allcontributors
specification. Contributions of any kind are welcome!