ks.test {ctest} | R Documentation |
Kolmogorov-Smirnov Tests
Description
Performs one or two sample Kolmogorov-Smirnov tests.
Usage
ks.test(x, y, ..., alternative = c("two.sided", "less", "greater"))
Arguments
x |
a numeric vector of data values. |
y |
either a numeric vector of data values, or a character string naming a distribution function. |
... |
parameters of the distribution specified by |
alternative |
indicates the alternative hypothesis and must be
one of |
Details
If y
is numeric, a two sample test of the null that x
and y
were drawn from the same distribution is performed.
Alternatively, y
can be a character string naming a
distribution function. In this case, a one sample test of the null
that the distribution function underlying x
is y
with
parameters specified by ... is carried out.
Currently, no exact p-values are available. The approximation by the limiting distribution may be inaccurate in small samples.
Value
A list with class "htest"
containing the following components:
statistic |
the value of the test statistic. |
p.value |
the p-value of the test. |
alternative |
a character string describing the alternative hypothesis. |
method |
a character string indicating what type of test was performed. |
data.name |
a character string giving the name(s) of the data. |
References
Conover, W. J. (1971), Practical nonparametric statistics. New York: John Wiley & Sons. Pages 295–301 (one-sample “Kolmogorov” test), 309–314 (two-sample “Smirnov” test).
See Also
shapiro.test
which performs the Shapiro-Wilk test for
normality.
Examples
x <- rnorm(50)
y <- runif(30)
# Do x and y come from the same distribution?
ks.test(x, y)
# Does x come from a shifted gamma distribution with shape 3 and scale 2?
ks.test(x+2, "pgamma", 3, 2) # two-sided
ks.test(x+2, "pgamma", 3, 2, alternative = "gr")