How To Forecast Using Gretl? A Practical Example -Part One

 In this post, I tried to explain how to make accurate economic/financial predictions using ARIMA (Auto-Regressive Integrated Moving Average) method in Gretl. To make it more clear and understandable, I also added screenshots for each step. The very first step for this is to make the data ready for model estimation. So I intended to explain the concepts of stationary/non-stationary data and how to detrend data in order to make it useful for time-series analysis.

  

Gretl is a very user-friendly tool to make econometric analyses. You can download it for free using the link: http://gretl.sourceforge.net/#dl. Then, depends on the operating system you use, choose the suitable option.

Guide on how to download Gretl for Microsoft and Mac users


Step-By-Step Guide For Forecasting Using ARIMA

1. Let's assume that you want to forecast Economic Policy Uncertainty Index for the United States, on a daily basis. Go to the website https://fred.stlouisfed.org/series/USEPUINDXD. First, you should download the data on a daily basis to a separate Microsoft Excel worksheet. Choose the starting and ending dates for your data and click on "Download". Then, choose the "Excel (data)" option and it is downloaded as an Excel file.

Economic Policy Uncertainy Index



Make sure you delete all unnecessary information on the document you have downloaded, and add titles for each column. Then, all you need to do is importing your file to Gretl. Just drag the file to Gretl and click on OK. Gretl will automatically recognize it. It will look like the picture below:

Gretl interface for in order to conduct forecasting on Economic Policy Uncertainty Index

2. Now, you should visualize your data to check if the series are stationary or not. One important fact to note is, in order to conduct ARIMA method for your predictions, your data must be stationary. In simplest words, you can say that the series is stationary if it does not show any upward/downward trend. Now, let's see how it is done:



The graph looks like this. Keep in mind that, you are going to make predictions based on this series as a whole. So, partial non-stationary just as in the picture below is not something you should consider. To make sure about the stationarity of your series, do more formal tests like checking Correlograms and Augmented Dickey-Fuller (ADF) Test.













3. Now, let's check correlograms first. Click on the Variable icon and then click on Correlogram. A new window will pop up, asking you how many lags you want to consider. Gretl automatically chooses the optimum lag number, so do not change it. Just click on OK.















Correlograms inform you about 2 things: First, about the stationarity of the series. Second, about how many lags we should consider in our ARIMA model. The rule of thumb is, if lags of ACF do not die down gradually, while the first lag of PACF is quite high, it signals non-statonarity! In our example, the case is exactly like that so you should suspect that the series is non-stationarity (Remember that examining the graph showed no clear trend for most of the series, which means stationarity. But Correlogram says opposite!). That is actually why we do more tests to check it, because eyeballing may be tricky sometimes.

Now, let's do one final test (ADF Test) to make the final decision. Null hypothesis of ADF test suggests that there exists a unit root and therefore the series is non-stationary. In order to perform it, you should click on Variable and then Unit root tests -  Augmented Dickey-Fuller test. Then, in the window that pops up, I suggest you to leave all options as default ones. Click OK.


















As you can see, according to the p-values, we fail to reject the null hypothesis for 95% confidence level (both p-values are greater than 0.05). Therefore, you can conclude that the series is non-stationary.

4. As the final step, you should transform your series to be stationary. For that, you can take the first derivative (If not enough, take the second derivative. For most of the cases, second derivative is enough). To do that, click on Add and then First differences of selected variables





















There is no clear trend visible. It looks stationary. Let's check Correlogram and ADF test as well.



























































Along with the graph, Correlogram and ADF test results also suggest that the series is stationary. Now you are ready to take the next step, which is model creation. In order to learn how to do that, you are more than welcome to check my next post titled as "How To Forecast Using Gretl? A Practical Example -Part Two".

Sources:

http://gretl.sourceforge.net/
https://fred.stlouisfed.org/series/USEPUINDXD

No comments:

Post a Comment