Basic Concepts
As described in Autocorrelation Introduction, if there is no autocorrelation, then the residuals are distributed randomly. In particular, in this case, the pattern of runs of positive and negative residuals would be random (ignoring any residual that is exactly zero). For this reason, we can use the Runs Test to detect autocorrelation.
Example using RUNSTEST formula
Referring to Figure 1 (a copy of Figure 1 of Autocorrelation Introduction), we can see from column G that the runs pattern of the residuals is
+ + + + – – – – – + +
Figure 1 – Detecting autocorrelation
Thus, if we use the formula =RUNSTEST(“++++—–++”,TRUE), we obtain the output shown in Figure 2.
Figure 2 – Runs Test to detect Autocorrelation
Since the p-value (or better yet the p-value for the exact test) is less than .05, we conclude that the pattern is not random, and so there is autocorrelation.
Example using Excel formulas
Note that we get the same outcome, manually, as shown in Figure 3.
Figure 3 – Manual calculation of runs test
Observation: The Runs Test has the advantage that it does not require that the residuals be normally distributed; in fact, no restriction is made whatsoever about the distribution.
Runs Up/Down Test
An alternative approach for testing for autocorrelation is to use the Runs Up/Down Test.
Figure 4 shows the results of the Runs Up/Down test on the data in Figure 1 using the array formula =RunsUpDn(G4:G14,TRUE).
Figure 4 – Runs Up/Down Test
This version of the runs test provides evidence that there isn’t autocorrelation (p-value = .27).
Examples Workbook
Click here to download the Excel workbook with the examples described on this webpage.
References
Becketti, S. (2023) Runtest. Stata
https://www.stata.com/manuals/rruntest.pdf
Meng, X. (2018) Tests for auto-correlation. Bucknell
https://www.eg.bucknell.edu/~xmeng/Course/CS6337/Note/master/node45.html
Hi!
I cannot get the array formula {=SUM(IF(G4:G13*G5:G14>0;0;1))+1} in L11 to work. Is it supposed to spill over to L12? Could you please clarify? (I have managed all the other steps=)
Best,
Jonas
Hi Jonas,
The actual formula is in cell J11. I just tried using it again, and it works fine. There is no spillover (when using Excel 365).
When you say that you couldn’t get the formula to work, did you get an error message or a different value?
Charles
Hi Charles can I know what is the N13 to find the p-value for therunstest?
Hi Belle,
I don’t see N13 on this webpage. What are you referring to?
Charles
It is the number os tails from the distribution, in this case it is actually in J12
Hello Vinicius,
Yes, you are correct. I will make the change on the webpage shortly.
Thank you very much for catching this error and making the website clearer and more accurate.
Charles
Hello Vinicius,
Yes, you are correct. I will make the change on the webpage shortly.
Thank you very much for catching this error and making the website clearer and more accurate.
Charles