| ks.test {ctest} | R Documentation |
Performs one or two sample Kolmogorov-Smirnov tests.
ks.test(x, y, ..., alternative = c("two.sided", "less", "greater"),
exact = NULL)
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 y. |
alternative |
indicates the alternative hypothesis and must be
one of "two.sided" (default), "less", or
"greater". You can specify just the initial letter. |
exact |
a logical indicating whether an exact p-value should be computed. Only used in the two-sided two-sample case. |
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.
The possible values "two.sided", "less" and
"greater" of alternative specify the null hypothesis
that the true distribution function of x is equal to, not less
than or not greater than the hypothesized distribution function
(one-sample case) or the distribution function of y (two-sample
case), respectively.
Currently, exact p-value are only available for the two-sided
two-sample test. In this case, by default (if exact is not
specified), an exact p-value is computed if the product of the sample
sizes is less than 10000. Otherwise, the asymptotic distributions are
used. This approximation may be inaccurate in small samples.
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. |
Conover, W. J. (1971), Practical nonparametric statistics. New York: John Wiley & Sons. Pages 295301 (one-sample ``Kolmogorov'' test), 309314 (two-sample ``Smirnov'' test).
shapiro.test which performs the Shapiro-Wilk test for
normality.
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")