Package {SMOARIMA}


Type: Package
Title: Automatic ARIMA Order Selection Using Spider Monkey Optimization
Version: 0.1.1
Maintainer: Mrinmoy Ray <mrinmoy4848@gmail.com>
Depends: R (≥ 4.0.0)
Imports: forecast, stats
Description: Implements automatic autoregressive integrated moving average order selection using the Spider Monkey Optimization algorithm. Candidate orders are evaluated using a weighted objective function that combines the Akaike information criterion and root mean square error. Functions support model fitting, forecasting, and forecast accuracy evaluation.
License: GPL-3
Encoding: UTF-8
NeedsCompilation: no
Packaged: 2026-07-29 06:24:30 UTC; majum
Author: Santosha Rathod [aut], Mrinmoy Ray [aut, cre], Chiranjit Mazumder [aut], Vishnu Shankar [aut], Fasila K. P. [aut], Sujith Arokiaswamy B. [aut], Anil Kumar [aut]
Repository: CRAN
Date/Publication: 2026-08-07 10:40:12 UTC

Accuracy Measures for SMO-ARIMA Model

Description

The accuracy_smo function computes forecast accuracy measures for a fitted SMO-ARIMA model using the observed values of the test series and the corresponding forecasts.

Usage

accuracy_smo(
  object,
  test
)

Arguments

object

An object of class "smoarima" returned by fit_smo().

test

A univariate test time series (ts) containing the observed values corresponding to the forecast horizon. For the internal holdout evaluation created by fit_smo(), use object$test.

Details

The accuracy_smo function compares the forecasts generated by the fitted SMO-ARIMA model with the observed test data and computes commonly used forecast accuracy measures. The function returns Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), Mean Squared Error (MSE), Root Mean Square Error (RMSE), and Mean Absolute Scaled Error (MASE).

Value

MAE

Mean Absolute Error.

MAPE

Mean Absolute Percentage Error.

MSE

Mean Squared Error.

RMSE

Root Mean Square Error.

MASE

Mean Absolute Scaled Error.

AIC

Akaike information criterion of the fitted model.

BIC

Bayesian information criterion of the fitted model.

References

Hyndman, R. J. and Koehler, A. B. (2006). Another look at measures of forecast accuracy. International Journal of Forecasting, 22(4), 679–688.

See Also

fit_smo, forecast_smo

Examples


data(AirPassengers)

fit <- fit_smo(
  AirPassengers,
  population = 4,
  groups = 2,
  max.iter = 2,
  p.max = 1,
  d.max = 1,
  q.max = 1,
  local.limit = 2,
  global.limit = 2
)

acc <- accuracy_smo(
  fit,
  fit$test
)

acc


Spider Monkey Optimization based ARIMA Model Fitting

Description

The fit_smo function automatically identifies the optimal ARIMA (p, d, q) model using the Spider Monkey Optimization (SMO) algorithm. The selected model is fitted to the input time series and returned as an object of class "smoarima".

Usage

fit_smo(
  data,
  population = 30,
  groups = 5,
  max.iter = 80,
  p.max = 3,
  d.max = 2,
  q.max = 3,
  alpha = 0.7,
  local.limit = 10,
  global.limit = 15,
  train.prop = 0.80,
  seed = 42
)

Arguments

data

Input univariate time series (ts) object.

population

Population size of the Spider Monkey Optimization algorithm. Default is 30.

groups

Number of spider monkey groups. Default is 5.

max.iter

Maximum number of optimization iterations. Default is 80.

p.max

Maximum autoregressive (AR) order. Default is 3.

d.max

Maximum differencing order. Default is 2.

q.max

Maximum moving average (MA) order. Default is 3.

alpha

Weight assigned to the normalized AIC in the objective function. The remaining weight (1-alpha) is assigned to the normalized RMSE. Default is 0.7.

local.limit

Maximum number of consecutive non-improving iterations allowed for a local leader before the corresponding group is reinitialized. Default is 10.

global.limit

Maximum number of consecutive non-improving iterations allowed for the global leader before group membership is reorganized. Default is 15.

train.prop

Proportion of observations assigned to the training sample used for model estimation during order selection. It must be strictly between 0 and 1. Default is 0.80.

seed

Random seed for reproducibility. Default is 42.

Details

The Spider Monkey Optimization (SMO) algorithm searches for the optimal ARIMA order (p,d,q) by minimizing a weighted objective function based on normalized Akaike Information Criterion (AIC) and Root Mean Square Error (RMSE).

Value

model

Fitted ARIMA model.

order

Selected ARIMA order (p,d,q).

coefficients

Estimated ARIMA coefficients.

fitted

Fitted values.

residuals

Model residuals.

AIC

Akaike Information Criterion.

BIC

Bayesian Information Criterion.

logLik

Log-likelihood of the fitted model.

runtime

Execution time (seconds).

convergence

Optimization convergence history.

References

Bansal, J. C., Sharma, H., Jadon, S. S. and Clerc, M. (2014). Spider Monkey Optimization Algorithm for Numerical Optimization. Memetic Computing, 6, 31–47.

Box, G. E. P., Jenkins, G. M., Reinsel, G. C. and Ljung, G. M. (2016). Time Series Analysis: Forecasting and Control. 5th Edition. Wiley.

See Also

accuracy_smo, forecast_smo

Examples


data(AirPassengers)

fit <- fit_smo(
  data = AirPassengers,
  population = 4,
  groups = 2,
  max.iter = 2,
  p.max = 1,
  d.max = 1,
  q.max = 1,
  local.limit = 2,
  global.limit = 2
)

fit$order

fit$AIC


Forecasting using Spider Monkey Optimized ARIMA Model

Description

The forecast_smo function generates forecasts from a fitted SMO-ARIMA model obtained using the fit_smo function. Point forecasts together with the corresponding prediction intervals are returned for the specified forecast horizon.

Usage

forecast_smo(
  object,
  h = 10,
  level = c(80, 95)
)

Arguments

object

An object of class "smoarima" returned by fit_smo().

h

Forecast horizon. Default is 10.

level

Confidence level(s) for prediction intervals. Default is c(80,95).

Details

The forecast_smo function generates forecasts from the fitted ARIMA model selected using the Spider Monkey Optimization (SMO) algorithm. Forecasts are produced for the specified forecast horizon, along with lower and upper prediction intervals corresponding to the requested confidence level(s).

Value

method

Forecasting method used.

model

Fitted SMO-ARIMA model.

mean

Point forecasts.

lower

Lower prediction limits.

upper

Upper prediction limits.

level

Confidence level(s) used for prediction intervals.

References

Hyndman, R. J. and Athanasopoulos, G. (2021). Forecasting: Principles and Practice. 3rd Edition. OTexts, Melbourne, Australia.

See Also

fit_smo, accuracy_smo

Examples


data(AirPassengers)

fit <- fit_smo(
  AirPassengers,
  population = 4,
  groups = 2,
  max.iter = 2,
  p.max = 1,
  d.max = 1,
  q.max = 1,
  local.limit = 2,
  global.limit = 2
)

fc <- forecast_smo(
  fit,
  h = 12,
  level = c(80, 95)
)

fc

plot(fc)