# How to build the univariate ARIMA model for time series in STATA?

By Priya Chetty & Divya Narang on February 6, 2018

Autoregressive Integrated Moving Average (ARIMA) is popularly known as the Box-Jenkins method. The emphasis of this method is on analyzing the probabilistic or stochastic properties of a single time series. Unlike regression models where Y is explained by X1 X2….XN regressor (like the introductory case where GDP is explained by GFC and PFC), ARIMA allows Y (GDP) to be explained by its own past or lagged values. ARIMA is performed on a single time series. Therefore it is termed as ‘univariate ARIMA’. In cases where ARIMA analysis includes independent variables (like GFC or PFC), then multivariate ARIMA model or ARIMAX models are suitable. This article focuses on the functioning of the univariate ARIMA model taking single time series GDP.

ARIMA is made up of AR, MA and I where:

• AR: variables regressed on their own lagged or prior values
• MA:  regression error representing the linear combination of error terms of repeated values
• I: indicates that the data values have been replaced with the difference between their values and the previous values (and this differencing process may have been performed more than once).

The purpose of each of these features is to make the model fit the data as well as, possible. This article will list out the procedures for assessing the values of AR, MA and I to build an ARIMA model for time series GDP. As the stationarity of GDP has already been covered in the previous articles, it can be stated that the value of I can be either 1 (1st differencing was stationary) or 2 (2nd differencing was stationary).  Furthermore, to explore the values of AR and MA, this article will introduce the terms ‘autocorrelation’ and ‘partial autocorrelation’.

## Correlogram (ac)

Correlograms are simply plots for extracting the autocorrelation in a particular time series. Autocorrelation is the presence of a series correlation in a time series data set. It implies that the time series (like GDP) can serially correlate with its own prior values. ‘Acf’ is an autocorrelation function plot to list out the autocorrelation of a particular time series with its various lags. If the time series administers the presence of auto-correlation, then Moving Averages (MA) are applicable for further analysis. Thus the value of MA will come through ACF plots. To construct ACF plots in STATA refer to Fig 1 below:

1. Click on ‘graphics’
2. Click on ‘time series graphs’
3. Select ‘correlogram (ac)’

A dialogue box as shown in the figure below will appear. Select the time series variable ‘GDP’. Stationarity and different time series of GDP as established in the previous article. Therefore consider different time series of GDP in this case. Also, two differences in GDP were taken. Therefore review the case of both the differencing series to build the ARIMA model.

### 1st Differenced GDP

In the dialogue box for correlogram (ac), select 1st differenced GDP variable that is ‘gdp_d1’. Click on ‘OK’ to generate acfs graph for variable ‘gdp_d1’ (figure below).

A correlogram visualizing the different autocorrelation of 1st difference of GDP (gdp_d1) at different lags will appear. Paste the detailed version of the correlogram as shown in the figure below. To determine autocorrelation, see which of all the lines are coming out of the shaded region. The shaded region indicates the acceptance region and the lines indicate different lags. Since for the first six lags, the lines are coming out of the shaded region, the series ‘gdp_d1’ is autocorrelated with its lagged series at lags 1, 2, 3, 4, 5 and 6. Therefore, the MA value of the ARIMA model can take a value from 1 to 6*.

### 2nd Differenced GDP

Similarly, for the 2nd difference GDP, select variable ‘gdp_d2’ (2nd differenced variable) as shown in figure 2, and create an ACF plot for it. A correlogram visualizing the different autocorrelation of 2nd difference of GDP (gdp_d2) at different lags will appear (figure below). Paste the detailed version of the correlogram (figure below). To determine autocorrelation, see which of all the lines are coming out of the shaded region. Since only for the first lag, the lines are coming out of the shaded region (acceptance region), the series ‘gdp_d2’ is autocorrelated with its lagged series at lags 1. Therefore, the MA value of the ARIMA model of series gdp_d2 can take the value from 1*.

Now there are different values of MA for all the different values of I. Therefore now estimate the values of AR to build the ARIMA model.

Get your research paper ready in 5 days. Use 634F71531FFB4 to get a discount of 3000 on 2001 - 3000 words emergency order.

## Partial correlogram (PAC)

A partial correlogram is simply a plot for extracting the partial autocorrelation in the selected time series. If the time series administers the presence of partial auto-correlation, then take AR for further analysis. Thus the value of AR will come through pacf plot. To construct pacf plots follow:

1. Click on ‘graphics’.
2. Click on ‘Time series graphs’.
3. Select ‘partial correlogram (PAC)’.

A dialogue box as shown in the figure below will appear. Here select the time series variable, ‘GDP’. Since stationarity was established and differenced time series of GDP was taken, consider differenced time series of GDP in this case. Now review the case of both the differencing series to build the ARIMA model.

### 1st differenced GDP

In the dialogue box for ‘partial correlogram (PAC)’, select 1st differenced GDP variable ‘gdp_d1’. Click on ‘OK’ to generate pacfs graph for variable ‘gdp_d1’.

A partial correlogram visualizing the different partial autocorrelation of 1st difference of GDP (gdp_d1) at different lags will appear. To determine autocorrelation, see which of all the lines are coming out of the shaded region. Since only for the first lag, the lines are coming out of the acceptance region, the series ‘gdp_d1’ partially auto correlates with its lagged series at lags 1. Therefore, the AR value of the ARIMA model can take the value from 1*.

### 2nd differenced GDP

Similarly, for 2nd difference GDP, select variable ‘gdp_d2’ (2nd differenced variable) as shown in figure 6, and create pacf for ‘gdp_d2’. Only for the first and four lags (a slight difference), the lines are slightly coming out of the shaded region (Fig 8). Therefore the series ‘gdp_d2’ partially auto correlates with its prior values at lags 1 and 4. Therefore, the AR value of the ARIMA model of series ‘gdp_d2’ can take the value from 1*.