README.md

forecastdom

Author: Gabriel Cabrera License: MIT + file LICENSE

CRAN status CRAN downloads License: MIT R-CMD-check Lifecycle: experimental pkgdown Codecov test coverage

Overview

forecastdom is an R toolkit for comparing the predictive ability of forecasting methods. It implements the four cells of the Li, Liao, and Quaedvlieg (2022) taxonomy (equal vs. superior, unconditional vs. conditional) plus tests for nested models, forecast encompassing, return predictability, and parameter instability.

Installation

# Install the released version from CRAN
install.packages("forecastdom")

# Or the development version from GitHub
# install.packages("devtools")
devtools::install_github("gabbocg/forecastdom")

Tests

Forecast Comparison

| Function | Test | Reference | |---|---|---| | dm_test() | Diebold-Mariano (+ HLN correction) | Diebold & Mariano (1995); Harvey, Leybourne & Newbold (1997) | | cw_test() | Clark-West MSFE-adjusted | Clark & West (2007) | | enc_new() | ENC-NEW Encompassing | Clark & McCracken (2001) | | mse_f_test() | McCracken MSE-F equal-MSFE | McCracken (2007) | | gw_test() | Giacomini-White (CEPA) | Giacomini & White (2006) | | spa_test() | Hansen's SPA (USPA) | Hansen (2005) | | cspa_test() | Conditional Superior Predictive Ability | Li, Liao & Quaedvlieg (2022) | | uspa_mh_test() | Uniform Multi-Horizon SPA | Quaedvlieg (2021) | | aspa_mh_test() | Average Multi-Horizon SPA | Quaedvlieg (2021) | | csms() | Confidence Set for the Most Superior | Li, Liao & Quaedvlieg (2022) |

Predictive Regression & Parameter Instability

| Function | Test | Reference | |---|---|---| | ivx_wald() | IVX-Wald for persistent predictors | Kostakis, Magdalinos & Stamatogiannis (2015) | | qll_hat() | Elliott-Muller parameter instability | Elliott & Muller (2006) |

Usage

Pairwise forecast comparison

library(forecastdom)

# Diebold-Mariano test with HLN correction
e1 <- rnorm(200)
e2 <- rnorm(200, mean = 0.1)
dm_test(e1, e2)

Conditional Superior Predictive Ability

# Simulate data from LLQ (2022) DGP
sim <- do_sim(J = 3, n = 500, a = 1.5, c = 0, rho_u = 0.4)

# CSPA test
result <- cspa_test(sim$Y, sim$X, level = 0.05, trim = 2)
result

# Visualization
cspa_test_plot(result)

Confidence Set for the Most Superior

# Compare multiple methods symmetrically
csms(losses, X, level = 0.05, trim = 2, method_names = c("AR1", "HAR", "HARQ", "LASSO"))

IVX-Wald test for return predictability

ivx_wald(returns, predictors, K = 1, M_n = floor(T ^ (1 / 3)))

Taxonomy

The four cells in Li, Liao, and Quaedvlieg (2022):

| | Equal accuracy | Superior accuracy | |---|---|---| | Unconditional | dm_test() | spa_test() | | Conditional | gw_test() | cspa_test() |

Equal vs. superior asks whether forecasts have the same loss or whether one is strictly lower. Unconditional vs. conditional asks whether the comparison holds on average or holds at every value of a conditioning variable.

Performance

The CSPA test uses Rcpp / C++ for the two hot loops (Gaussian-process column maxima and the binary search over the p-value).

Getting help

If you encounter a bug, please file an issue with a minimal reproducible example on GitHub. For questions, email gabriel.cabrera.guz@gmail.com.

References



Try the forecastdom package in your browser

Any scripts or data that you put into this service are public.

forecastdom documentation built on Nov. 2, 2026, 1:10 a.m.