Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 10 down vote accepted

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

Definitely.

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

Strictly, the null you're testing against is equality, but if you're among the (large) group of people that write 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 (this recollection would well be wrong), 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.

share|improve this answer
1  
"In large enough samples, it's possible for the F's to cross - even several times, and still reject the one-sided test" – note that this means that you can reject the one-sided test in both directions for the same data! –  Hao Ye Jul 12 at 0:44
1  
@HaoYe Yes, that's possible. It would be a clear indication that stochastic dominance would be untenable. –  Glen_b Jul 12 at 1:24
1  
Alexis: The logic is simple - you choose the statistic sensitive to the kinds of deviations you expect if the alternative is true. See the added part at the end, which goes through it for an $F_Y<F_0$ alternative. The converse case should be obvious from that one. –  Glen_b Jul 12 at 5:17
    
I've moved my lengthy comments up into my answer. –  Glen_b Jul 12 at 23:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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