Till now, you have studied different Auto Regressive models. In this segment, you will study about another Auto Regressive model which **models an external variable** along with the non-seasonal and seasonal components.

**SARIMAX has three components**

- Non-seasonal elements

Models future observation as a linear regression of past observations and past forecast errors.

Performs differencing to make time-series stationary.

- Seasonal elements

Models seasonality as the linear regression of past observations and past forecast errors from previous seasons.

Perform seasonal differencing to make time-series stationary over seasons.

- Exogenous variable

Models future observations as linear regression of external variable.

**Example**

Forecast quarterly ice cream sales for 2020 when you have the data of quarterly sales of the ice cream for the last 4 years.

In the above time plot, sales data displays trend and seasonality but peaks are not periodic. The peak in 2017 has appeared in the first quarter, while in 2018 it has appeared in the 2nd quarter and again it has appeared in the first quarter of 2018. Thus, it is evident that peaks, in spite of being close to summer, are not periodic.

If we know this promotion period for the quarter, it will help us to forecast the sales more accurately.

**Equations:**

**SARIMAX(1,0,0)(0,1,1)4**

$$//https://www.internetknowledgehub.com/report-technical-or-content-error///$$

The parameters** ‘p’, ‘d’, ‘q’ **and** ‘P’, ‘D’, ‘Q’ **will be the same as SARIMA(p,d,q)(P,D,Q)m.

- Determining parameter values.

PACF plots to determine non-seasonal ‘p’ value.

ACF plots to identify non-seasonal ‘q’ value.

- Use stationarity tests to determine the value ‘d’.

- Use grid search to choose optimal seasonal P, D and Q parameter values.

So, you have got a theoretical understanding of the SARIMAX model. Let us now build the SARIMAX model using Python.

The promotion dataset used in the demonstration to build SARIMAX can be downloaded from here:

Since you have a good understanding of SARIMAX, attempt the following questions before proceeding.