By Jacques Joubert
About two weeks ago I decided to attempt to write a blog series on Pairs trading and statistical arbitrage. What I found is that everyone tends to reference the ADF test but I really don’t see a lot of posts that explain the test in full.
As you read about building a pairs trading strategy there is talk of testing a pair for co-integration and then you learn that they use ADF to do this. However when I looked up tests for co-integration, the ADF test was not on the short list. Rather, an ADF test features under the topic: Testing for a Unit Root.
Fortunately for me my wife studied actuarial sciences and my house is littered with text books. I really thought it would be as easy as picking up a time series book and learning about ADF but that idea was shot down like the slow duck in the reeds. In short I would have to read about 6 chapters of time series analysis before getting to a point where I can understand the different ways that you can use the ADF to test for a unit root and to use the ADF test in the context of stat arb.
If there are any readers that know of a resource that could explain the test in full, an article that tries to express to the reader in the most basic of terms, pretty please attach a link to the comments section. (Later on in the week I found this URL http://robotwealth.com/exploring-mean-reversion-and-cointegration-part-2/)
This week’s mantra: Mathematicians that can communicate concepts to the everyday man will go very far in life.
I eventually resorted to using the method explained in my QuantInsti EPAT lectures, this serves as a supplementary to their already written blog series, explained below:
Step 1: Get data for two securities that you want to perform an ADF test on
In this example I use a South African Listed company called Mondi that has two listings on the Johannesburg Stock Exchange.
Step 2: Perform a linear regression on the two securities using a set number of observations
I will use 60 observations. Make sure you also request the residuals to be outputted. Note: When running this in a pairs trading strategy you will have to run the ADF test everyday to make sure the Null hypothesis is rejected (Null hypothesis = there is a unit root).
Make sure you check Residuals
The X Variable Coefficient of 0.78255 is what we will be using for the hedge ratio.
Step 3: Calculate the difference between the residuals
Step 4: Calculate the t-1 residual in the next column
Step 5: Perform a linear regression on the Delta and t-1 column
Step 6: Compare the t test statistic and the critical value
In order to reject the null hypothesis that the there is a unit root present, the t statistic must in this case be smaller than the critical value. The critical values for an ADF test have their own distribution and here is a snap shot at some of the critical values:
- We will be using the Critical value of -2.89, we have less than 100 observations
- The t stat is – 3.369
- Therefore the null hypothesis is rejected and we can say that the data are co-integrated
This test needs to be performed for every single data point and I would argue that that this will not be done in excel. Therefore if you want to run a pairs trading strategy using a technique that includes testing for co-integration using an ADF test then I would recommend you to do so in say Python, R, C++, etc.
Note: Since writing this, one of the mentors from the EPAT program showed me how to run an ADF test in excel on every data point using the LINEST function, I would encourage others to check it out if your adamant on sticking with excel.