Kolmogorov-Smirnov Test – Is it Sensible to Perform a One-Tailed Test?

goodness of fithypothesis testingkolmogorov-smirnov test

Is it meaningful and possible to perform a one-tailed KS test? What would the null hypothesis of such a test be? Or is the KS test inherently a two-tailed test?

I would benefit from an answer that helped me understand the distribution of $D$ (I am working through Massey's 1951 paper, and find the description challenging, for example are $D^{+}$ and $D^{-}$ the supremum and infimum of the differences of the non-absolute value of differences in empirical CDFs?).

Followup question: how are $p$-values for $D^{+}$ and $D^{-}$ obtained? So many of the publications I am encountering are presenting tabled values, rather than CDF of $D_{n}$, $D^{+}$ and $D^{-}$.

Update: I just discovered the related question What's the null hypothesis in a one-sided Kolmogorov-Smirnov test?, which I missed on my initial scan before writing this one.

Best Answer

Is it meaningful and possible to perform a one-tailed KS test?

Definitely, in the sense that one-tailed is generally used with the Kolmogorov-Smirnov. Because we're talking about many differences at once (the cdf is a function, not a value), the direction of a difference is not a single fixed thing - the cdf might be greater at one place and less at another (so both directional tests might be significant at the same time).

is the KS test inherently a two-tailed test?

Not at all.

What would the null hypothesis of such a test be?

You don't make it clear whether you're talking about the one-sample or the two sample test. My answer here covers both - if you regard $F_X$ as representing the cdf of the population from which an $X$ sample was drawn, it's two-sample, while you get the one sample case by regarding $F_X$ as some hypothesized distribution ($F_0$, if you prefer).

You could in some cases write the null as an equality (e.g.if it wasn't seen as possible for it to go the other way), but if you want to write a directional nulls for a one tailed alternative, you could write something like this:

$H_0: F_Y(t)\geq F_X(t)$

$H_1: F_Y(t)< F_X(t)\,$, for at least one $t$

(or its converse for the other tail, naturally)

If we add an assumption when we use the test that they're either equal or that $F_Y$ will be smaller, then rejection of the null implies (first order) stochastic ordering / first order stochastic dominance. In large enough samples, it's possible for the F's to cross - even several times, and still reject the one-sided test, so the assumption is strictly needed for stochastic dominance to hold.

Loosely if $F_Y(t)\leq F_X(t)$ with strict inequality for at least some $t$ then $Y$ 'tends to be bigger' than $X$.

Adding assumptions like this is not weird; it's standard. It's not particularly different from assuming (say in an ANOVA) that a difference in means is because of a shift of the whole distribution (rather than a change in skewness, where some of the distribution shifts down and some shifts up, but in such a way that the mean has changed).


So let's consider, for example, a shift in mean for a normal:

enter image description here

The fact that the distribution for $Y$ is shifted right by some amount from that for $X$ implies that $F_Y$ is lower than $F_X$. The one-sided Kolmogorov-Smirnov test will tend to reject in this situation.

Similarly, consider a scale shift in a gamma:

enter image description here

Again, the shift to a larger scale produces a lower F. Again, the one-sided Kolmogorov-Smirnov test will tend to reject in this situation.

There are numerous situations where such a test may be useful.


So what are $D^+$ and $D^-$?

In the one-sample test, $D^+$ is the maximum positive deviation of the sample cdf from the hypothesized curve (that is the biggest distance the ECDF is above $F_0$, while $D^-$ is the maximum negative deviation - the biggest distance the ECDF is below $F_0$). Both $D^+$ and $D^-$ are positive quantities:

enter image description here

A one tailed Kolmogorov-Smirnov test would look at either $D^+$ or $D^-$ depending on the direction of the alternative. Consider the one tailed one sample test:

$H_0: F_Y(t)\geq F_0(t)$

$H_1: F_Y(t)< F_0(t)\,$, for at least one $t$

To test this one - we want sensitivity to $Y$ being stochastically larger than hypothesized (its true $F$ is lower than $F_0$). So unusually large values of $D^-$ will tend to occur when the alternative is true. As a result, to test against the alternative $F_Y(t)< F_0(t)$, we use $D^-$ in our one-tailed test.


Follow-up question: how are p-values for $D^+$ and $D^−$ obtained?

It's not a simple thing. There are a variety of approaches that have been used.

If I recall correctly one of the ways the distribution was obtained via the use of Brownian bridge processes (this document seems to support that recollection).

I believe this paper, and the paper by Marsaglia et al here both cover some of the background and give computational algorithms with lots of references.

Between those, you'll get a lot of the history and various approaches that have been used. If they don't cover what you need, you'll probably need to ask this as a new question.

So many of the publications I am encountering are presenting tabled values, rather than CDF of $D_n$, $D^+$ and $D^−$

That's not particularly a surprise. If I remember right, even the asymptotic distribution is obtained as a series, and in finite samples it's discrete and not in any simple form. In either case and there's no convenient way to present the information except as either a graph or a table.