# What is a reasonable independence test for a time series?

Suppose that I have a time series, $x_{1:n}$, and I would like to test whether they are all independent samples from the uniform distribution on $[0,1]$. This is a somewhat basic question, but how do I correctly test for that?

I am using the Kolmogorov-Smirnov test to check that they are uniform.

One thing I can do is calculate the autocorrelation function for $x_{1:n}-\frac12$, which should be small. It should lie within approximately $\pm 2/\sqrt{n}$ and I can calculate the Ljung-Box and Box-Pierce statistics. My only concern with them is that if I repeatedly calculate them for just known-random data, e.g., rand(1000,1), the distribution of p-values for both of them is not quite uniform. Which, if I understand correctly, means they are not very good tests. What would be a good test for independence?

## 1 Answer

It's not possible, in general, to "test for independence" unless you have a perfect unsupervised learning algorithm. The tests you mention look for small autocorrelations. If the only kind of dependence you expect to find is lagging, then that seems to me like the best you can do.

What other kinds of dependencies do you imagine you will run into? If you know that, then maybe you can craft a test for it.