Package 'arimasel'

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

Help Index


arimasel: 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. 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.

Details

Key functions: cart_arima, arima_forecast, arima_diagnose, compare_arima, stationarity_test, suggest_d, cp_sets, hqic, arima_weights.

Author(s)

Olushina Olawale Awe [email protected]

References

Awe, O. O. (2026). arimasel: Cartesian Product-Based ARIMA Model Identification and Selection. R package version 0.1.0.


Residual Diagnostics for a cartARIMA Object

Description

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.

Usage

arima_diagnose(object, lags = NULL, ...)

Arguments

object

An object of class "cartARIMA".

lags

Maximum lag for Ljung-Box and ACF/PACF. Default: min(20, floor(n / 5)).

...

Additional graphical parameters.

Value

Invisibly returns a list with ljung_box (data.frame) and shapiro_wilk.

See Also

cart_arima

Examples

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)

Forecast Fan Chart for cartARIMA Objects

Description

Produces a publication-quality gradient fan chart showing point forecasts and multiple simultaneous prediction intervals shaded with progressively lighter fills.

Usage

arima_fanplot(x, h = 12L, levels = c(0.50, 0.80, 0.95),
              history = 36L, ...)

Arguments

x

An object of class "cartARIMA".

h

Integer; forecast horizon. Default: 12.

levels

Numeric vector of coverage probabilities for the fan bands. Default: c(0.50, 0.80, 0.95).

history

Integer; number of in-sample observations to display before the forecast origin. Default: 36. Use NULL to show the full series.

...

Additional graphical parameters passed to plot.

Value

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).

See Also

cart_arima, arima_forecast, plot.cartARIMA

Examples

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)

Forecast from a Cartesian Product ARIMA Result

Description

Produces h-step-ahead point forecasts and prediction intervals from the best model or an Akaike-weighted ensemble of the top-k models.

Usage

arima_forecast(object, h = 10L, ensemble = FALSE, top_k = NULL,
               level = c(80, 95), plot = TRUE, ...)

Arguments

object

An object of class "cartARIMA".

h

Positive integer forecast horizon. Default 10L.

ensemble

Logical; compute Akaike-weighted ensemble? Default FALSE.

top_k

Number of ensemble members. Default min(5, n_converged).

level

Confidence levels for prediction intervals. Default c(80, 95).

plot

Logical; produce plot? Default TRUE.

...

Additional graphical parameters.

Value

A list (invisibly) with mean, lower, upper, ensemble_mean, level, model, and top_k.

See Also

cart_arima

Examples

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)

Format and Re-rank the ARIMA Model Comparison Table

Description

Extracts and optionally re-ranks the model comparison table from a "cartARIMA" object, with Akaike weights recomputed for the chosen criterion.

Usage

arima_table(object, criterion = NULL, top_n = NULL)

Arguments

object

An object of class "cartARIMA".

criterion

Ranking criterion. One of "AIC", "AICc", "BIC", "HQIC". NULL (default) retains the original.

top_n

Number of rows to return. NULL returns all models.

Value

A data.frame with columns Model, p, d, q, LogLik, AIC, AICc, BIC, HQIC, Rank, Delta, Weight.

See Also

cart_arima

Examples

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)

Akaike Weights and Evidence Ratios

Description

Given a numeric vector of information criterion values (lower = better), computes Akaike weights and evidence ratios relative to the best model.

Usage

arima_weights(criteria_values, names_vec = NULL)

Arguments

criteria_values

A numeric vector of IC values, length >= 2.

names_vec

Optional character vector of model names.

Value

A data.frame with columns Model, IC_value, Delta, Weight, EvidenceRatio, sorted by ascending Delta.

See Also

cart_arima

Examples

ic_vals <- c(ARIMA_110 = 200.1, ARIMA_011 = 198.4, ARIMA_210 = 201.7)
arima_weights(ic_vals)

Cartesian Product ARIMA Model Identification and Selection

Description

Exhaustively fits every ARIMA(p,d,q) model in the Cartesian product P×D×QP \times D \times Q, 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.

Usage

cart_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2,
           criterion = c("AIC", "AICc", "BIC", "HQIC"),
           top_n = 10L, ...)

Arguments

x

A numeric vector or ts object (minimum 10 observations).

p_set

Integer vector of AR orders p≥0p \ge 0. Default 0:2.

d_set

Integer vector of differencing orders d≥0d \ge 0. Default 0:1.

q_set

Integer vector of MA orders q≥0q \ge 0. Default 0:2.

criterion

Primary ranking criterion: "AIC" (default), "AICc", "BIC", or "HQIC".

top_n

Maximum rows in the abbreviated table (obj$table). Default 10L.

...

Additional arguments to arima, e.g. method = "ML".

Value

An object of class "cartARIMA" with components:

best_model

Fitted Arima object for the top-ranked model.

best_model_str

Character string, e.g. "ARIMA(1,1,1)".

criterion

Primary ranking criterion used.

table

Top top_n models (data.frame).

full_table

All converged models (data.frame).

vote_table

Criterion-vote counts per model.

failed_models

Character vector of models that failed.

n_total

Total candidates attempted.

n_converged

Models that converged.

p_set, d_set, q_set

Index sets used.

data

Original series (ts).

n_obs

Length of the original series.

call

Matched call.

References

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.

See Also

arima_table, arima_forecast, arima_diagnose, compare_arima, cp_sets

Examples

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)

Methods for cartARIMA Objects

Description

Standard S3 methods for objects of class "cartARIMA" returned by cart_arima.

Usage

## 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, ...)

Arguments

x, object

An object of class "cartARIMA".

type

Character; one of:

"criteria"

Horizontal bar chart of IC values.

"lollipop"

Cleveland lollipop chart of IC values (modern bar alternative).

"weights"

Bar chart of Akaike model weights.

"bubble"

Bubble chart: rank vs IC value, bubble area = Akaike weight.

"surface"

Criterion heat map over the p x q grid.

"fitted"

Observed vs fitted overlay with residual shading.

"dashboard"

Six-panel comprehensive summary dashboard.

criterion

IC criterion to display: "AIC", "AICc", "BIC", or "HQIC". Defaults to the criterion used in cart_arima().

top_n

Integer; how many top models to include in plots. Default: 10.

k

Numeric penalty per parameter for AIC (default: 2).

...

Further arguments passed to underlying plot functions.

Value

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.

See Also

cart_arima, arima_fanplot

Examples

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")

Compare cart_arima with auto.arima

Description

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.

Usage

compare_arima(x, p_set = 0:2, d_set = 0:1, q_set = 0:2,
              criterion = "AIC", holdout = 0L, ...)

Arguments

x

A numeric vector or ts object.

p_set, d_set, q_set

Index sets passed to cart_arima.

criterion

Primary criterion for cart_arima. Default "AIC".

holdout

Test set size. 0L disables holdout. Default 0L.

...

Additional arguments passed to cart_arima.

Value

A list with cart_arima_result, comparison_table, auto_arima_model, and winner.

See Also

cart_arima

Examples

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)

Cartesian Product of ARIMA Parameter Sets

Description

Displays and returns the Cartesian product of user-supplied AR, differencing, and MA index sets, listing all candidate ARIMA(p,d,q) models.

Usage

cp_sets(p_set = 0:2, d_set = 0:1, q_set = 0:2)
## S3 method for class 'cartProduct'
print(x, ...)

Arguments

p_set

Non-negative integer vector of AR orders. Default 0:2.

d_set

Non-negative integer vector of differencing orders. Default 0:1.

q_set

Non-negative integer vector of MA orders. Default 0:2.

x

A cartProduct object (for the print method).

...

Currently unused.

Value

An object of class "cartProduct" (invisibly) containing p_set, d_set, q_set, product, n_models, and model_strings.

See Also

cart_arima

Examples

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 USD/NGN Exchange Rate – Nigeria, 2010-2023

Description

Monthly US dollar to Nigerian Naira exchange rate from January 2010 to December 2023, including structural breaks from major CBN policy shifts.

Usage

data(exchange_ng)

Format

A ts object of length 168 with frequency = 12.

Examples

data(exchange_ng)
plot(exchange_ng, main = "USD/NGN Exchange Rate")

Annual GDP Growth Rate – Nigeria, 1990-2023

Description

Annual time series of Nigeria's GDP growth rate (percent) from 1990 to 2023.

Usage

data(gdp_ng)

Format

A ts object of length 34 with frequency = 1.

Examples

data(gdp_ng)
plot(gdp_ng, main = "Nigeria Annual GDP Growth Rate (%)")

Hannan-Quinn Information Criterion

Description

Computes the Hannan-Quinn Information Criterion (HQIC) for a fitted ARIMA model: HQIC=−2ℓ^+2kln⁡(ln⁡n)\mathrm{HQIC} = -2\hat\ell + 2k\ln(\ln n).

Usage

hqic(object, k = 2)

Arguments

object

A fitted model of class "Arima" (from arima).

k

Penalty multiplier. Default 2.

Value

A single numeric value.

References

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.

Examples

x <- cumsum(rnorm(80))
fit <- arima(x, order = c(1, 1, 0))
hqic(fit)

Monthly CPI Inflation Rate – Nigeria, 2000-2023

Description

Monthly CPI year-on-year inflation rate (percent) for Nigeria from January 2000 to December 2023.

Usage

data(inflation_ng)

Format

A ts object of length 288 with frequency = 12.

Examples

data(inflation_ng)
plot(inflation_ng, main = "Nigeria Monthly CPI Inflation (%)")

Battery of Stationarity Tests

Description

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.

Usage

stationarity_test(x, lags = NULL, alpha = 0.05)

Arguments

x

A numeric vector or ts object (minimum 10 observations).

lags

ADF lag order. NULL uses ⌊(n−1)1/3⌋\lfloor(n-1)^{1/3}\rfloor.

alpha

Significance level. Default 0.05.

Value

A data.frame with columns Test, Statistic, p_value, Conclusion, and attributes consensus and suggested_d.

See Also

suggest_d, cart_arima

Examples

set.seed(5)
x <- cumsum(rnorm(80))
stationarity_test(x)

Recommend a Differencing Order

Description

Applies ADF tests iteratively to the original and differenced series to recommend the differencing order dd.

Usage

suggest_d(x, max_d = 2L, alpha = 0.05, verbose = FALSE)

Arguments

x

A numeric vector or ts object.

max_d

Maximum differencing order. Default 2L.

alpha

Significance level. Default 0.05.

verbose

Logical; print test results. Default FALSE.

Value

A single non-negative integer.

See Also

stationarity_test

Examples

set.seed(9)
x <- cumsum(rnorm(80))
suggest_d(x, verbose = TRUE)