Path: blob/master/Time Forecasting using Python/ 5 ARIMA model for exogeneous variables ARIMAX.ipynb
3074 views
In ARIMA (AutoRegressive Integrated Moving Average) models, exogenous variables, often denoted as Xt, are external factors or predictors that are not part of the time series being analyzed but may influence it. These variables are used to enhance the forecasting performance of the model by incorporating additional information that can help explain the variability in the dependent variable.
In a basic ARIMA model, only the past values of the time series itself are used to make forecasts. However, in the presence of exogenous variables, the ARIMA model becomes an ARIMAX (AutoRegressive Integrated Moving Average with eXogenous variables) model. Forecasting equation incorporates both the autoregressive (AR) terms and the moving average (MA) terms, as well as any exogenous variables if present.
Example Forecasting Equation for ARIMA(2,0,1) with Exogenous Variable
Given the parameters of the model:
Extracting the Forecast Equation
To ensure the forecast equation matches the model's output exactly, you can extract the parameters from the fitted model and manually compute the forecast
Solving ARIMA Mathematically
example where we have monthly sales data for a product over the past few years and we want to forecast future sales using ARIMA(2,0,1) with an exogenous variable, which in this case could be advertising expenditure on the product.
Suppose we have the following data:
Month: January, February, March, ..., December
Sales (Y): 100, 120, 110, ..., 150
Advertising Expenditure (X): 5000, 5500, 6000, ..., 7000
We will first fit the ARIMA(2,0,1) model with the exogenous variable using the provided data. Then, we will use the fitted model to forecast sales for the next few months.
Step 1: Fit ARIMA(2,0,1) with Exogenous Variable Model
Step 2: Forecast Future Sales
Once the model is fitted, we can use it to forecast sales for the next few months by providing future values of the exogenous variable
Calculations
Step 2: Forecast Future Sales
Suppose we want to forecast sales for the next 3 months and we have the following advertising expenditures for those months:
Advertising Expenditure for Month 1 (Next month): 7500
Advertising Expenditure for Month 1 (Next month): 8000
Advertising Expenditure for Month 3 (Three months ahead):8500 We will use the fitted model to forecast sales for these months
These equations give us forecasts for the sales in the next 3 months, considering the influence of the exogenous variable (advertising expenditure). We can solve these equations iteratively to obtain numerical forecasts.
!pip install wordcloud --trusted-host pypi.org --trusted-host files.pythonhosted.org --upgrade statsmodels
ARIMA(2,1,1) with exogenous variables
a=[0,1,2,3]