Autoregressive Integrated Moving Average (ARIMA)

The Autoregressive Integrated Moving Average (ARIMA) model is a powerful statistical tool used for time series forecasting. It is designed to identify and exploit patterns in time series data, making it particularly useful in the field of algorithmic trading, where accurate predictions of future prices can lead to profitable trading strategies. ARIMA models can handle a variety of time series characteristics, including trends and seasonality, making them a versatile choice for traders and data scientists alike.

Components of ARIMA

ARIMA models are composed of three main components:

  1. Autoregressive (AR) term: This component uses past values of the series to model the current value. The number of lagged observations included is denoted by the parameter p.
  2. Integrated (I) term: This component represents the differencing applied to the series to make it stationary, which is a prerequisite for many time series models to function correctly. The level of differencing is indicated by the parameter d.
  3. Moving Average (MA) term: This component uses past forecast errors in a regression model to predict future values. The number of lagged forecast errors is denoted by the parameter q.

Autoregressive (AR) Term

The autoregressive part of the ARIMA model is essentially a regression of the time series on itself. It assumes that the current value of the series can be explained by a linear combination of its previous values. Mathematically, the AR term can be expressed as:

Z_t = c + \sum_{i=1}^{p} \phi_i Z_{t-i} + \epsilon_t

Integrated (I) Term

The integrated part of the ARIMA model involves differencing the time series data to make it stationary. Stationarity means that the statistical properties of the series, such as mean and variance, are constant over time. A non-stationary series can have trends, seasonality, and other structures that need to be eliminated to apply ARIMA effectively. The differencing process can be mathematically represented as:

\Delta Y_t = Y_t - Y_{t-1}

Applying the first difference twice gives the second difference.

\Delta^2 Y_t = Y_t - 2Y_{t-1} + Y_{t-2}

The parameter d indicates the number of times differencing is applied.

BTC/USD Daily candles Kraken
StockSharp JS-Charts

The three lines use daily closing prices. The seasonal difference compares closes separated by the selected number of days.

Loading candle history…

Moving Average (MA) Term

The moving average part of the ARIMA model involves using past forecast errors to predict future values. This component accounts for the unexplained part of the series by incorporating the errors from previous periods. The mathematical representation of the MA term is:

Z_t = \mu + \epsilon_t + \sum_{j=1}^{q}\theta_j\epsilon_{t-j}

One-step forecast on daily BTC/USD

With both components, the forecast is the sum of the intercept, the lagged values of the differenced series and the lagged errors. The model converts the forecast back to price using the observed closes before the target day. Clear the MA coefficients to use the AR-only equation. Clear the AR coefficients to use the MA-only equation. Box–Jenkins model definition

\hat{Z}_t = c + \sum_{i=1}^{p}\phi_i Z_{t-i} + \sum_{j=1}^{q}\theta_j\epsilon_{t-j}
BTC/USD Daily candles Kraken
StockSharp JS-Charts

Each forecast uses earlier daily closes and errors. Enter up to eight coefficients in each field, one per line. An empty field removes that lag component. AR coefficients must be stationary and MA coefficients invertible. Initial errors are zero at the start of each continuous segment.

Loading candle history…

Model Identification

Before an ARIMA model can be constructed, it’s crucial to identify the appropriate values of the parameters p, d, and q. This process involves several steps:

  1. Differencing to achieve stationarity: Plot the time series and difference it until it appears stationary. The number of differences applied will determine the parameter d.
  2. Autocorrelation Function (ACF) and Partial Autocorrelation Function (PACF): Examine the ACF and PACF plots to identify the potential values of p and q.
    • The ACF plot shows the correlation between the time series and its past values.
    • The PACF plot shows the partial correlation after removing the influence of earlier lags.

ACF and PACF Interpretation

Building the ARIMA Model

Once the parameters p, d, and q are determined, the next step is to fit the ARIMA model to the time series data. This involves estimating the coefficients and validating the model through residual diagnostics.

Parameter Estimation

The parameters of the ARIMA model are typically estimated using the Maximum Likelihood Estimation (MLE) method. This method finds the parameter values that maximize the likelihood function, ensuring that the observed data is most probable under the fitted model.

Model Diagnostics

After fitting the model, it’s essential to validate it to ensure that the residuals (the differences between the observed and fitted values) resemble white noise, indicating that all patterns have been adequately captured by the model.

Model Validation and Forecasting

Once the model diagnostics indicate a good fit, the ARIMA model can be used for forecasting. It’s important to evaluate the model’s performance using out-of-sample data to ensure its predictive power.

Forecast Accuracy Metrics

Common metrics to assess forecast accuracy include:

Forecasting

The ARIMA model can generate forecasts by projecting the time series into the future, using the fitted parameters and past values. The forecasting process involves:

  1. Predicting future values using the ARIMA model equations.
  2. Constructing confidence intervals around the forecasts to account for uncertainty.

Seasonal ARIMA (SARIMA)

For time series with seasonality, the Seasonal ARIMA (SARIMA) model extends the basic ARIMA framework by incorporating seasonal autoregressive and moving average terms. The SARIMA model is denoted as:

\operatorname{SARIMA}(p,d,q)\times(P,D,Q)_s

Where:

Seasonal AR and MA coefficients apply at lags s,2s,3s,\dots. The chart multiplies the ordinary and seasonal lag polynomials and applies both orders of differencing. Seasonal Box–Jenkins model

BTC/USD Daily candles Kraken
StockSharp JS-Charts

Each forecast uses earlier daily closes and errors. Enter up to eight coefficients in each field, one per line. An empty field removes that lag component. AR coefficients must be stationary and MA coefficients invertible. Initial errors are zero at the start of each continuous segment.

Loading candle history…

Seasonal Differencing

Seasonal differencing involves subtracting the value from the same season in the previous period. For example, first-order seasonal differencing can be represented as:

\Delta_s Y_t = Y_t-Y_{t-s}

Where s is the seasonal period.

SARIMA Model Identification

Identifying SARIMA models requires analyzing seasonal lags in the ACF and PACF plots and applying the same principles used for non-seasonal ARIMA models.

ARIMA in Algorithmic Trading

In algorithmic trading, ARIMA models are used to forecast asset prices, volatility, and other financial metrics. Accurate forecasts enable traders to design strategies that exploit predicted market movements.

Practical Considerations

Example Use Case

A trader might use an ARIMA model to forecast the closing prices of a stock. By fitting a model to historical price data, the trader can predict future prices and develop a trading strategy based on these predictions. For instance, if the forecast indicates a rising trend, the trader might take a long position, while a declining trend might prompt a short position.

Software and Tools for ARIMA

Several software tools and libraries facilitate the implementation of ARIMA models:

Python

R

MATLAB

Conclusion

The ARIMA model is a versatile and powerful tool for time series forecasting, with extensive applications in algorithmic trading. By capturing patterns in historical data, ARIMA models enable traders to make informed decisions, enhancing their profitability. Proper model identification, validation, and application are essential to harness the full potential of ARIMA models in predicting future market movements.