12
$\begingroup$

The question says it all. I've read both that one can't generalize KS to a dimension equal or larger than two, and that famous implementations like that in Numerical Recipes are simply wrong. Could you please explain why is so?

$\endgroup$
2
  • $\begingroup$ I added some tags (bivariate, empirical, and cdf), on the basis of the quoted (in my answer) section of the paper. $\endgroup$
    – Glen_b
    Commented May 27, 2014 at 2:45
  • $\begingroup$ pedrofigueira - I have made substantial changes to my answer (my original was wrong; sorry about that). I will likely make more edits because I intend to come back with references to several multivariate K-S tests. $\endgroup$
    – Glen_b
    Commented May 27, 2014 at 22:51

1 Answer 1

16
$\begingroup$

I believe it's legitimate to quote the relevant portion of the paragraph in question:

3. The KS test can not be applied in two or more dimensions. Astronomers often have datasets with points distributed in a plane or higher dimensions, rather than along a line. Several papers in the astronomical literature purport to present a two-dimensional KS test, and one is reproduced in the famous volume Numerical Recipes. However, no EDF-based test (this includes KS, AD and related tests) can be applied in two or higher dimensions, because there is no unique way to order the points so that distances between well-defined EDFs can be computed. One can construct a statistic based on some ordering procedure, and then compute the supremum distances between two datasets (or one dataset and a curve). But the critical values of the resulting statistic are not distribution-free.

As stated, this seems too strong.

1) The bivariate distribution function, which is $F(x_1,x_2) = P(X_1\leq x_1,X_2\leq x_2)$ is a map from $\mathbb{R}^2$ to $[0,1]$. That is, the function takes univariate real values between 0 and 1. Those values - being probabilities - are certainly "ordered" already - and this (the value of the function) is the thing we need to make comparisons on for ECDF-based tests. Similarly, the ecdf, $\hat F$ is perfectly well defined in the bivariate case.

I don't think there's necessarily a need to try to turn it into some function of a univariate combined variable as the text suggests. You simply compute $F$ and $\hat F$ at every required combination and compute the difference.

2) However, on the question of whether it's distribution-free, they have a point:

a) clearly such a test statistic would not be altered by changes to transformations of the margins, which is to say, if constructed as a test of bivariate independent uniforms, $\mathbf{U}=(U_1,U_2)$, then it works equally well as a test of independent $(X_1,X_2)$ where $U_i=F_i(X_i)$. In that sense, it's distribution-free (we might say 'margin-free').

b) however, there's an underlying point more generally in the broader sense that a naive version of the KS statistic (such as I just described) is not more generally distribution free; we can't simply transform $U$ arbitrarily $X^* = \mathbf{g}(\mathbf{U})$.

In an earlier version of my answer I said:

There's no difficulty, no problem

That's wrong. There are indeed issues if there's a change not just of the margins from bivariate independent uniforms, as just mentioned. However, those difficulties have been considered in several ways in a number of papers that yield bivariate/multivariate versions of Kolmogorov-Smirnov statistics that don't suffer from that problem.

I may come back and add some of those references and some discussion of how they work as soon as time permits.

$\endgroup$
5
  • $\begingroup$ This answer is clearly correct, but beware: that the KS test can be used, doesnt mean it should be used. Usually there are far better tests (more powerfull) ones. $\endgroup$ Commented May 27, 2014 at 10:11
  • $\begingroup$ Certainly - though it depends on what alternatives are of interest. $\endgroup$
    – Glen_b
    Commented May 27, 2014 at 10:51
  • 1
    $\begingroup$ I do not fully understand this answer. I imagine many astronomical datasets (as well as many other small-dimensional datasets) do not come with intrinsically meaningful coordinate systems. Thus your claim that the points are "ordered already" would be invalid in such circumstances. It could be rescued if you were able to show that the KS statistic is independent of the coordinates used to identify the locations. I don't think that's true in two or more dimensions, but I could be mistaken. $\endgroup$
    – whuber
    Commented May 27, 2014 at 21:21
  • 1
    $\begingroup$ @whuber I've made substantial changes in the light of your very kind response to my error. I will likely make further changes as I add references and more details in the hopes of making an answer that will be more useful in the longer term. $\endgroup$
    – Glen_b
    Commented May 27, 2014 at 22:54
  • $\begingroup$ (+1) Thank you very much, Glen, for broadening this reply and making it more nuanced. Although I find the OP's reference of dubious quality (at the outset it misinterprets what hypothesis tests mean), it finally admits that "the bootstrap can come to the rescue, and significance levels for the particular multidimensional statistic and the particular dataset under study can be numerically computed." This seems aligned, at least in spirit, with how your answer is shaping up. $\endgroup$
    – whuber
    Commented May 27, 2014 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.