Skip to content

Arima

  • ARIMA models combine autoregressive (AR), differencing (I), and moving average (MA) components to forecast time series.
  • Differencing (the “I” component) is used to make a series stationary before applying AR and MA parts.
  • Model orders are specified by the numbers of AR terms, differences, and MA terms (examples in the example below).

ARIMA, short for Auto-Regressive Integrated Moving Average, is a commonly used time series forecasting method in statistics used to model and predict future values based on historical data and trends. The model consists of three components: the autoregressive (AR) component, the differencing (I) component, and the moving average (MA) component.

  • Autoregressive (AR) component: models the relationship between current values and past values. Example from the source: if the current stock price is influenced by the previous three stock prices, the autoregressive component would be AR(3).
  • Differencing (I) component: used to make the time series stationary (constant mean, variance, and autocorrelation over time). For a series with a trend, differencing removes the trend and makes the data stationary.
  • Moving average (MA) component: models the relationship between the current value and past error terms (the difference between the actual value and the predicted value). Example from the source: if the current stock price is influenced by the previous three error terms, the moving average component would be MA(3).

Stationarity is important because many statistical models assume stationary data. Differencing (for example, taking first differences) is a common method to achieve stationarity before fitting ARIMA.

Original monthly sales data:

Month123456789101112
Sales100105110115120125130135140145150155

First differences (as shown in the source):

Month123456789101112
Sales-55555555555

The example fits an ARIMA(1,1,0) model: AR(1) (current value influenced by the previous value), I(1) (first differences taken), MA(0) (no moving average component).

Code shown in the source (imports, data load, fit, and predict): import pandas as pd import numpy as np from statsmodels.tsa.arima_model import ARIMA

# Load the data into a DataFrame
data = pd.DataFrame({"sales": [100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155]})
# Fit the ARIMA model
model = ARIMA(data, order=(1,1,0))
model_fit = model.fit(disp=False)
# Make predictions for the next 12 months
predictions = model_fit.predict(start=13, end=24, dynamic=True)

The predictions are shown below: Month: 1 2

  • Time series forecasting and prediction of future values from historical trends (as described in the source).
  • Stationarity is required for many statistical models; differencing is used in ARIMA to achieve stationarity by removing trends.
  • The MA component depends on past error terms (the difference between actual and predicted values).
  • Autoregressive (AR)
  • Differencing / Integration (I)
  • Moving average (MA)
  • Stationarity
  • statsmodels (Python library referenced in the example)