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).
Definition
Section titled “Definition”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.
Explanation
Section titled “Explanation”- 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.
Examples
Section titled “Examples”Monthly sales example
Section titled “Monthly sales example”Original monthly sales data:
| Month | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Sales | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 |
First differences (as shown in the source):
| Month | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Sales | -5 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 5 |
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 DataFramedata = pd.DataFrame({"sales": [100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155]})
# Fit the ARIMA modelmodel = ARIMA(data, order=(1,1,0))model_fit = model.fit(disp=False)
# Make predictions for the next 12 monthspredictions = model_fit.predict(start=13, end=24, dynamic=True)The predictions are shown below: Month: 1 2
Use cases
Section titled “Use cases”- Time series forecasting and prediction of future values from historical trends (as described in the source).
Notes or pitfalls
Section titled “Notes or pitfalls”- 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).
Related terms
Section titled “Related terms”- Autoregressive (AR)
- Differencing / Integration (I)
- Moving average (MA)
- Stationarity
- statsmodels (Python library referenced in the example)