# [R] Kolmogorov-Smirnov Test - what are the exact alternative hypotheses?

B Dittmann herrdittmann at yahoo.co.uk
Tue Jan 31 20:00:48 CET 2006

```Hi everyone,

I have performed the Kolmogorov-Smirnov test (ks.test) with R the first
time.

What I am not sure about is the exact alternative hypotheses (H1) given
any H0.

According to Conover (1971) Practical Nonparametric Statistics, chapter
6, the following one-sample tests can be performed:

(1) Two-sided test

H0: F(x) = F*(x)
H1: F(x) =/= F*(x) [for at least one x]

(2) one-sided test

(2.a): "less"

H0: F(x) =< F*(x)
H1: F(x) > F*(x) [for at least one x]

(2.b): "greater"

H0: F(x) >= F*(x)
H1: F(x) < F*(x) [for at least one x]

with F(x) being the empirical distribution of sample data and F*(x) the
hypothesised distribution. F*(x) requires full specification, which can
be achieved by "fitdistr(..., F*(x)).

The KS Test on R tests a sample performs a 2-sided test as default mode.
The choice for "alternative" seems to allow for a choice of H0 different
to the standard of two-sided.

Suppose one would chooses "less" or "greater" as "alternative". Does the
KS test automatically set the correct H1?
Whenever I perform the test, the alternative hypothesis is not being
stated, that is why I am not certain whether I would be correct to make
this assumption.

Here is an example of the output for a test:
P*(x) is a lognormal distribution, fully specified with meanlog and sdlog.

=====================

> ks.test(spread,plnorm, meanlog=2.359, sdlog=0.588, alternative =
"greater")

One-sample Kolmogorov-Smirnov test

D^+ = 0.035, p-value = 0.0462
alternative hypothesis: greater

Warning message:
cannot compute correct p-values with ties in: ks.test(spread, plnorm,
meanlog = 2.359, sdlog = 0.588, alternative = "greater")

======================

In the above test I am testing one-sided, i.e. (2.b) above. Does ks.test
automatically set H1 such that "F(x) < F*(x) for at least one x"?