| Title: | Cartesian Product-Based ARIMA Model Identification and Selection |
|---|---|
| Description: | Provides an alternative algorithm for ARIMA model identification based on Cartesian products of user-supplied parameter sets. Rather than relying on ACF/PACF plots or stepwise search (as in auto.arima), the package exhaustively evaluates every ARIMA(p,d,q) triple in P x D x Q, ranks all converged models by AIC, AICc, BIC, and HQIC simultaneously, computes Akaike weights for model uncertainty quantification, produces ensemble forecasts, and provides publication-quality diagnostic plots. The algorithm is flexible, transparent, and widely applicable for quick, reproducible ARIMA model selection. Applications are demonstrated with Nigerian macroeconomic time series data. |
| Authors: | Olushina Olawale Awe [aut, cre]
|
| Maintainer: | Olushina Olawale Awe <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-10-18 11:08:51 UTC |
| Source: | https://github.com/olawaleawe/arimasel |
Provides an alternative algorithm for ARIMA model identification based on Cartesian products of user-supplied parameter sets. The package exhaustively evaluates every ARIMA(p,d,q) triple in P x D x Q, ranks models by four information criteria, computes Akaike weights, and supports ensemble forecasting.
Key functions: cart_arima, arima_forecast,
arima_diagnose, compare_arima,
stationarity_test, suggest_d,
cp_sets, hqic, arima_weights.
Olushina Olawale Awe [email protected]
Awe, O. O. (2026). arimasel: Cartesian Product-Based ARIMA Model Identification and Selection. R package version 0.1.0.
Six-panel residual diagnostic plot for the best ARIMA model: residuals over time, ACF, PACF, histogram with Normal density, Q-Q plot, and Ljung-Box p-values by lag.
arima_diagnose(object, lags = NULL, ...)arima_diagnose(object, lags = NULL, ...)
object |
An object of class |
lags |
Maximum lag for Ljung-Box and ACF/PACF. Default:
|
... |
Additional graphical parameters. |
Invisibly returns a list with ljung_box (data.frame) and
shapiro_wilk.
set.seed(3) x <- arima.sim(list(ar = 0.5), n = 80) res <- cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2) arima_diagnose(res, lags = 15)set.seed(3) x <- arima.sim(list(ar = 0.5), n = 80) res <- cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2) arima_diagnose(res, lags = 15)
Produces a publication-quality gradient fan chart showing point forecasts and multiple simultaneous prediction intervals shaded with progressively lighter fills.
arima_fanplot(x, h = 12L, levels = c(0.50, 0.80, 0.95), history = 36L, ...)arima_fanplot(x, h = 12L, levels = c(0.50, 0.80, 0.95), history = 36L, ...)
x |
An object of class |
h |
Integer; forecast horizon. Default: 12. |
levels |
Numeric vector of coverage probabilities for the fan bands.
Default: |
history |
Integer; number of in-sample observations to display before
the forecast origin. Default: 36. Use |
... |
Additional graphical parameters passed to |
Invisibly returns a named list with elements mean (numeric vector of
point forecasts), lower, and upper (each a matrix with one
column per level in levels).
cart_arima, arima_forecast, plot.cartARIMA
set.seed(42) x <- arima.sim(list(ar = 0.7, ma = 0.3), n = 120) res <- cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2) arima_fanplot(res, h = 12)set.seed(42) x <- arima.sim(list(ar = 0.7, ma = 0.3), n = 120) res <- cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2) arima_fanplot(res, h = 12)
Produces h-step-ahead point forecasts and prediction intervals from the best model or an Akaike-weighted ensemble of the top-k models.
arima_forecast(object, h = 10L, ensemble = FALSE, top_k = NULL, level = c(80, 95), plot = TRUE, ...)arima_forecast(object, h = 10L, ensemble = FALSE, top_k = NULL, level = c(80, 95), plot = TRUE, ...)
object |
An object of class |
h |
Positive integer forecast horizon. Default |
ensemble |
Logical; compute Akaike-weighted ensemble? Default |
top_k |
Number of ensemble members. Default |
level |
Confidence levels for prediction intervals. Default |
plot |
Logical; produce plot? Default |
... |
Additional graphical parameters. |
A list (invisibly) with mean, lower, upper,
ensemble_mean, level, model, and top_k.
set.seed(7) x <- arima.sim(list(ar = 0.6), n = 80) res <- cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2) arima_forecast(res, h = 8, ensemble = TRUE, top_k = 3)set.seed(7) x <- arima.sim(list(ar = 0.6), n = 80) res <- cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2) arima_forecast(res, h = 8, ensemble = TRUE, top_k = 3)
Extracts and optionally re-ranks the model comparison table from a
"cartARIMA" object, with Akaike weights recomputed for the
chosen criterion.
arima_table(object, criterion = NULL, top_n = NULL)arima_table(object, criterion = NULL, top_n = NULL)
object |
An object of class |
criterion |
Ranking criterion. One of |
top_n |
Number of rows to return. |
A data.frame with columns Model, p, d, q, LogLik, AIC, AICc,
BIC, HQIC, Rank, Delta, Weight.
set.seed(1) x <- arima.sim(list(ar = 0.5), n = 80) res <- cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2) arima_table(res, criterion = "BIC", top_n = 5)set.seed(1) x <- arima.sim(list(ar = 0.5), n = 80) res <- cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2) arima_table(res, criterion = "BIC", top_n = 5)
Given a numeric vector of information criterion values (lower = better), computes Akaike weights and evidence ratios relative to the best model.
arima_weights(criteria_values, names_vec = NULL)arima_weights(criteria_values, names_vec = NULL)
criteria_values |
A numeric vector of IC values, length >= 2. |
names_vec |
Optional character vector of model names. |
A data.frame with columns Model, IC_value, Delta, Weight,
EvidenceRatio, sorted by ascending Delta.
ic_vals <- c(ARIMA_110 = 200.1, ARIMA_011 = 198.4, ARIMA_210 = 201.7) arima_weights(ic_vals)ic_vals <- c(ARIMA_110 = 200.1, ARIMA_011 = 198.4, ARIMA_210 = 201.7) arima_weights(ic_vals)
Exhaustively fits every ARIMA(p,d,q) model in the Cartesian product
, ranks all converged models by AIC, AICc, BIC,
and HQIC simultaneously, computes Akaike weights, and returns the best
model together with a full comparison table.
cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2, criterion = c("AIC", "AICc", "BIC", "HQIC"), top_n = 10L, ...)cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2, criterion = c("AIC", "AICc", "BIC", "HQIC"), top_n = 10L, ...)
x |
A numeric vector or |
p_set |
Integer vector of AR orders |
d_set |
Integer vector of differencing orders |
q_set |
Integer vector of MA orders |
criterion |
Primary ranking criterion: |
top_n |
Maximum rows in the abbreviated table ( |
... |
Additional arguments to |
An object of class "cartARIMA" with components:
best_modelFitted Arima object for the top-ranked model.
best_model_strCharacter string, e.g. "ARIMA(1,1,1)".
criterionPrimary ranking criterion used.
tableTop top_n models (data.frame).
full_tableAll converged models (data.frame).
vote_tableCriterion-vote counts per model.
failed_modelsCharacter vector of models that failed.
n_totalTotal candidates attempted.
n_convergedModels that converged.
p_set, d_set, q_set
Index sets used.
dataOriginal series (ts).
n_obsLength of the original series.
callMatched call.
Box, G. E. P., Jenkins, G. M., Reinsel, G. C., and Ljung, G. M. (2015). Time Series Analysis: Forecasting and Control (5th ed.). John Wiley & Sons.
Akaike, H. (1974). A new look at the statistical model identification. IEEE Transactions on Automatic Control, 19(6), 716–723.
Awe, O. O. (2026). arimasel: Cartesian Product-Based ARIMA Model Identification and Selection. R package version 0.1.0.
arima_table, arima_forecast,
arima_diagnose, compare_arima,
cp_sets
set.seed(42) x <- arima.sim(list(ar = 0.7, ma = -0.3), n = 100) result <- cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2) print(result) summary(result)set.seed(42) x <- arima.sim(list(ar = 0.7, ma = -0.3), n = 100) result <- cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2) print(result) summary(result)
Standard S3 methods for objects of class "cartARIMA" returned by
cart_arima.
## S3 method for class 'cartARIMA' print(x, ...) ## S3 method for class 'cartARIMA' summary(object, ...) ## S3 method for class 'cartARIMA' plot(x, type = c("criteria", "lollipop", "weights", "bubble", "surface", "fitted", "dashboard"), criterion = NULL, top_n = 10L, ...) ## S3 method for class 'cartARIMA' coef(object, ...) ## S3 method for class 'cartARIMA' residuals(object, ...) ## S3 method for class 'cartARIMA' fitted(object, ...) ## S3 method for class 'cartARIMA' AIC(object, ..., k = 2) ## S3 method for class 'cartARIMA' BIC(object, ...) ## S3 method for class 'cartARIMA' logLik(object, ...)## S3 method for class 'cartARIMA' print(x, ...) ## S3 method for class 'cartARIMA' summary(object, ...) ## S3 method for class 'cartARIMA' plot(x, type = c("criteria", "lollipop", "weights", "bubble", "surface", "fitted", "dashboard"), criterion = NULL, top_n = 10L, ...) ## S3 method for class 'cartARIMA' coef(object, ...) ## S3 method for class 'cartARIMA' residuals(object, ...) ## S3 method for class 'cartARIMA' fitted(object, ...) ## S3 method for class 'cartARIMA' AIC(object, ..., k = 2) ## S3 method for class 'cartARIMA' BIC(object, ...) ## S3 method for class 'cartARIMA' logLik(object, ...)
x, object
|
An object of class |
type |
Character; one of:
|
criterion |
IC criterion to display: |
top_n |
Integer; how many top models to include in plots. Default: 10. |
k |
Numeric penalty per parameter for |
... |
Further arguments passed to underlying plot functions. |
print and plot return x invisibly.
summary returns object invisibly.
coef, residuals, fitted, AIC, BIC,
and logLik return the corresponding quantities from the best model.
set.seed(1) x <- arima.sim(list(ar = 0.6), n = 100) res <- cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2) print(res) summary(res) ## individual plot types plot(res, type = "lollipop") plot(res, type = "weights") plot(res, type = "bubble") plot(res, type = "fitted") plot(res, type = "dashboard")set.seed(1) x <- arima.sim(list(ar = 0.6), n = 100) res <- cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2) print(res) summary(res) ## individual plot types plot(res, type = "lollipop") plot(res, type = "weights") plot(res, type = "bubble") plot(res, type = "fitted") plot(res, type = "dashboard")
Fits a Cartesian product model and, if forecast is installed,
compares it with auto.arima on in-sample information criteria
and optionally on out-of-sample forecast accuracy.
compare_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2, criterion = "AIC", holdout = 0L, ...)compare_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2, criterion = "AIC", holdout = 0L, ...)
x |
A numeric vector or |
p_set, d_set, q_set
|
Index sets passed to |
criterion |
Primary criterion for |
holdout |
Test set size. |
... |
Additional arguments passed to |
A list with cart_arima_result, comparison_table,
auto_arima_model, and winner.
set.seed(11) x <- arima.sim(list(ar = 0.6), n = 80) compare_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2)set.seed(11) x <- arima.sim(list(ar = 0.6), n = 80) compare_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2)
Displays and returns the Cartesian product of user-supplied AR, differencing, and MA index sets, listing all candidate ARIMA(p,d,q) models.
cp_sets(p_set = 0:2, d_set = 0:1, q_set = 0:2) ## S3 method for class 'cartProduct' print(x, ...)cp_sets(p_set = 0:2, d_set = 0:1, q_set = 0:2) ## S3 method for class 'cartProduct' print(x, ...)
p_set |
Non-negative integer vector of AR orders. Default |
d_set |
Non-negative integer vector of differencing orders. Default |
q_set |
Non-negative integer vector of MA orders. Default |
x |
A |
... |
Currently unused. |
An object of class "cartProduct" (invisibly) containing
p_set, d_set, q_set, product, n_models,
and model_strings.
cp_sets(0:1, 0:1, 0:1) cp_sets(p_set = c(0,1,2), d_set = 1, q_set = c(0,1))cp_sets(0:1, 0:1, 0:1) cp_sets(p_set = c(0,1,2), d_set = 1, q_set = c(0,1))
Monthly US dollar to Nigerian Naira exchange rate from January 2010 to December 2023, including structural breaks from major CBN policy shifts.
data(exchange_ng)data(exchange_ng)
A ts object of length 168 with frequency = 12.
data(exchange_ng) plot(exchange_ng, main = "USD/NGN Exchange Rate")data(exchange_ng) plot(exchange_ng, main = "USD/NGN Exchange Rate")
Annual time series of Nigeria's GDP growth rate (percent) from 1990 to 2023.
data(gdp_ng)data(gdp_ng)
A ts object of length 34 with frequency = 1.
data(gdp_ng) plot(gdp_ng, main = "Nigeria Annual GDP Growth Rate (%)")data(gdp_ng) plot(gdp_ng, main = "Nigeria Annual GDP Growth Rate (%)")
Computes the Hannan-Quinn Information Criterion (HQIC) for a fitted
ARIMA model: .
hqic(object, k = 2)hqic(object, k = 2)
object |
A fitted model of class |
k |
Penalty multiplier. Default |
A single numeric value.
Hannan, E. J. and Quinn, B. G. (1979). The determination of the order of an autoregression. Journal of the Royal Statistical Society, Series B, 41(2), 190–195.
x <- cumsum(rnorm(80)) fit <- arima(x, order = c(1, 1, 0)) hqic(fit)x <- cumsum(rnorm(80)) fit <- arima(x, order = c(1, 1, 0)) hqic(fit)
Monthly CPI year-on-year inflation rate (percent) for Nigeria from January 2000 to December 2023.
data(inflation_ng)data(inflation_ng)
A ts object of length 288 with frequency = 12.
data(inflation_ng) plot(inflation_ng, main = "Nigeria Monthly CPI Inflation (%)")data(inflation_ng) plot(inflation_ng, main = "Nigeria Monthly CPI Inflation (%)")
Runs the Augmented Dickey-Fuller (ADF) test and, if the tseries package is installed, the Phillips-Perron (PP) and KPSS tests. Returns a tidy summary with a consensus conclusion.
stationarity_test(x, lags = NULL, alpha = 0.05)stationarity_test(x, lags = NULL, alpha = 0.05)
x |
A numeric vector or |
lags |
ADF lag order. |
alpha |
Significance level. Default |
A data.frame with columns Test, Statistic, p_value, Conclusion,
and attributes consensus and suggested_d.
set.seed(5) x <- cumsum(rnorm(80)) stationarity_test(x)set.seed(5) x <- cumsum(rnorm(80)) stationarity_test(x)
Applies ADF tests iteratively to the original and differenced series to
recommend the differencing order .
suggest_d(x, max_d = 2L, alpha = 0.05, verbose = FALSE)suggest_d(x, max_d = 2L, alpha = 0.05, verbose = FALSE)
x |
A numeric vector or |
max_d |
Maximum differencing order. Default |
alpha |
Significance level. Default |
verbose |
Logical; print test results. Default |
A single non-negative integer.
set.seed(9) x <- cumsum(rnorm(80)) suggest_d(x, verbose = TRUE)set.seed(9) x <- cumsum(rnorm(80)) suggest_d(x, verbose = TRUE)