# How to prove that the probability of spurious correlation increases with random walk length?

Define a simple random walk $$y_{t}$$ as:

$$y_{t} = y_{t-1} + 2\times Bernoulli\left(0.5\right)-1,$$

so that at time $$t$$ the value of $$y$$ equals its previous value plus a perturbation from the "flip-a-coin" distribution: 50% chance of heads ($$+1$$), and 50% chance of tails ($$-1$$).

I simulated pairs of random walks of length $$T$$, where $$T$$ ranges from $$4$$ to $$200$$ one million times for each value of $$T$$. For each simulated pair of random walks, I estimated Spearman's correlation coefficient $$\hat{\rho}_{S}$$, and calculated the $$t$$ test statistic corresponding to $$H_{0}: \rho_{S} = 0$$, and determined the (two-tailed) $$p$$ value from that $$t$$ test statistic. ‘Spurious correlation’ is a well known consequence of naïve application of correlation measures to such non-stationary (i.e. ‘integrated’ data) as illustrated in the graph below, which depicts the probability that a $$p$$ value was less than an $$\alpha=0.05$$ vs. the length $$T$$ of the random walk length of paired simulations of $$y_{t}$$. (Not shown are graphs for other values of $$\alpha$$ reflecting the same qualitative pattern.) Can one prove that such a curve increases monotonically as $$\boldsymbol{\lim_{T \to \infty}}$$?
(Or prove that it does not.)

Obviously, my approach is numeric, and I should be considered a newb for analytic answers. The distribution of $$p$$ values under a true $$H_{0}$$ should be uniform from 0 to 1 (and ideally cleave to a horizontal line at the value of $$\alpha$$ on the same kind of graph as above), so I assume that I am asking how to prove that this distribution is increasingly non-uniform as $$T$$ increases.

• This is a consequence of the distribution of the correlation coefficient (rapidly) reaching a limiting distribution that is continuous in a neighborhood of zero. As the length increases, the test becomes more and more sensitive and so the p-value becomes more and more likely to lie below any given positive number, with the chance of that bounded above only by $1$. Thus, if you would like better insight, I would suggest studying the distribution of the correlation coefficient itself rather than examining it so indirectly through the p-values. – whuber Nov 10 '17 at 22:28
• whuber gives an answer to a related question worth looking at here. – Glen_b Nov 11 '17 at 1:02

This isn't a direct answer to your question but provides some pointers that relate to the asymptotic distribution of the Pearson correlation in a Gaussian random walk. (Neither replacing Spearman with Pearson nor a Bernoulli random walk with a Gaussian is going to be of much consequence asymptotically; the Spearman may make a small difference, the increments to the random walk should make no difference asymptotically)

There's been a fair amount of work on this kind of problem in the econometrics literature -- unsurprisingly.

Phillips (1986) gives information about the asymptotic behaviour of $$R^2$$,

$$R^2 \mathbf{\Rightarrow} \frac{\zeta^2\left\{\int_0^1 W(t)^2\, \mathrm{d}t- (\int_0^1 W(t)\, \mathrm{d}t)^2 \right\}}{\int_0^1 V(t)^2\, \mathrm{d}t- (\int_0^1 V(t) \,\mathrm{d}t)^2}\,,$$

where

$$\zeta = \frac{\int_0^1 V(t)W(t)\, \mathrm{d}t\,- \int_0^1 V(t)\, \mathrm{d}t\int_0^1 W(t)\, \mathrm{d}t }{\int_0^1 W(t)^2\, \mathrm{d}t\,-\, (\int_0^1 W(t)\, \mathrm{d}t)^2}$$

and $$V$$ and $$W$$ are independent Wiener processes; at another point Phillips explains $$\mathbf{\Rightarrow}$$ (which should be able to be carried over, mutatis mutandis):

The notation ‘$$\mathbf{\Rightarrow}$$’ [...] is used to signify the weak convergence of the probability measure of $$Z_T(t)$$ to the probability measure (here, multivariate Wiener measure) of the random function $$Z(t)$$.

(p317 and appendix) while Marmol(1996) discusses Bannerjee et al. (1993) who describe the density of R (rather than $$R^2$$):

When both variables are I(1), the density of R is close to a semi-ellipse with excess frequency at both ends of the distribution and, consequently, values of R well away from zero are far more likely here than in [the case of two I(0) series].

(I didn't get hold of Bannerjee et al)

I don't agree with their characterization of the shape of the distribution of R; convergence to the limiting case seems to be very rapid, and the shape is almost flat over the middle half of the range: Those are histograms of the distribution of the correlation of independent $$I(1)$$ series (cumulated Gaussian) of different lengths -- $$n=10,100,1000,10000$$, with 100,000 values generated for each case. We see that the distribution hardly changes between 10 and 100, and seems to be essentially stable after that. It looks to me like a slightly rounded off symmetric trapezium (/trapezoid), flat in the middle half of the range.

Meanwhile the null distribution (under the assumption of independent $$I(0)$$ series) would be $$N(0,\frac{1}{n})$$; the standard deviation decreases as $$1/\sqrt{n}$$; this means more and more of the above distribution is in the critical region as we take longer series.

Here's the corresponding histograms for the Bernoulli random walk and Spearman correlation: Those are histograms of the distribution of the Spearman correlation of independent cumulated random $$\pm 1$$ values for series of varying lengths -- $$n=10,100,1000,10000$$, with 100,000 values generated for each case.

The equilibrium distribution looks about the same as for the Pearson/Gaussian case, but is perhaps just a little "rounder" (less flat in the middle half).

(Some additional simulations show that this slight difference is indeed mainly due to the Spearman/Pearson difference rather than the binomial/Gaussian)

Nevertheless, even if the distribution is very slightly different, the result will be the same -- both tests will see a very similar increase rejection rate with sample size.

So for random walks we have this stable distribution that settles down pretty quickly with sample size and then stays the same, but the standard deviation of the null distribution of the correlation coefficient shrinks as $$1/\sqrt{n}$$ so more and more of this distribution will lie in the rejection region as $$n$$ increases.

Looked at another way -- under the null hypothesis, $$\sqrt{n}\,r$$ is approximately standard normal, but because the distribution of these correlations don't shrink around zero as sample size increases, $$\sqrt{n}\,r$$ gets wider with $$n$$ -- less and less of it will lie within $$0 \pm z_{1-\alpha/2}$$ as $$n$$ increases.

Phillips, P.C.B, (1986),
"Understanding Spurious Regressions in Econometrics"
Journal of Econometrics, 33, p311-340.

However the published version has a number of printing issues so you may also want this working version to be able to get some of the details:
https://cowles.yale.edu/sites/default/files/files/pub/d07/d0757.pdf

Marmol, F., (1996),
Correlation theory of spuriously related higher order integrated processes,
Economics Letters, 50, 169-173

Banerjee, A., Dolado, J.J., Galbraith, J.W. and D.F. Hendry, (1993),
Co-integration, error-correction, and the econometric analysis of non-stationary data
(Oxford University Press, Oxford).

• Thank you, Glen_b. I indeed read that Phillips paper following the link you gave to the other question with whuber's answer. I especially took note of (c) and (d) of Theorem 3.1. Nevertheless, I am trying my own proof! Please feel free to hit me with Incisive, Yet Useful Comments. :) – Alexis Nov 13 '17 at 1:34

Ok, I am gonna try and take whuber's advice to attend to the distribution of $\rho_{\text{s}}$. I do not have a mathematical statistics background, so gentle prodding me to make my thinking more rigorous is welcome.

Here goes:

1. The random walk length $T$ is a natural number.

2. There are $2^{T}$ possible random walks of this form for a specific value of $T$. This is because for each time $t$ from $1$ to $T$ has two possible outcomes.

3. There are therefore $2^{2T}$ possible pairs of of random walks, for a specific value of $T$ (i.e. there are $2^{T}$ possible random walks to pair with each random walk of length $T$).

4. For all values of $T>3$, $\rho_{\text{s}} \ne 0$, for $T=3$ half the values of $\rho_{\text{s}} \ne 0$; for $T=2$ all four values of $\rho_{\text{s}} \ne 0$. Therefore, $E(\rho_{\text{s}}) \ne 0$ for all $T$. (This is because for all random walks $\text{cov}(\text{rank}(RW_{1}), \text{rank}(RW_{2}))$ is non-zero, except in half the cases when $T=3$.)

5. As $\lim{T \to \infty}$, $\sigma_{\rho_{\text{s}}}$ gets small as fast as $n^{3} - n$. Therefore $E(t)$ gets big, and $E(p)$ gets small as $T$ grows.