Detecting Autocorrelation via Runs Test

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

+ + + + – – – – – + +

First-order autocorrelation

Figure 1 – Detecting autocorrelation

Thus, if we use the formula =RUNSTEST(“++++—–++”,TRUE), we obtain the output shown in Figure 2.

Runs Test for Autocorrelation

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.

Runs test autocorrelation manual

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).

Runs Up/Down test

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

7 thoughts on “Detecting Autocorrelation via Runs Test”

  1. 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

    Reply
    • 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

      Reply

Leave a Comment