ks.test(x, y, ..., alternative = c("two.sided", "less", "greater"), exact = NULL, distribution = "normal")
x | a numeric vector that contains the sample values from one of the distributions. Missing values (NAs) and infinite values (Infs) are ignored. | ||||||
y |
two-sample test:
a numeric vector that contains the sample values for the two-sample test.
Missing values (NAs) and infinite values (Infs) are ignored.
one-sample test:
a character string that specifies the function that generates p-values for the hypothesized distribution,
which can be one of pnorm, pbeta, pcauchy, pchisq, pexp, pf, pgamma, plnorm,
plogis, pt, punif, pweibull, pbinom, pgeom, phyper, pnbinom, ppois, pwilcox.
| ||||||
alternative |
a character string that specifies the alternative hypothesis.
To test the hypothesis, type one of the following:
| ||||||
... | For the one-sample test, parameter arguments for the function that generates p-values for the hypothesized distribution. For example, if y = "pnorm", those arguments will be passed down to pnorm. | ||||||
exact |
logical value that specifies if the function should compute an exact p-value.
exact is valid only in the case of two-sided and where there are no duplicates in the sample values, that is, where there are no ties. If you do not specify a value for exact, the function sets exact = FALSE except in the following cases:
| ||||||
distribution | a character string that specifies the hypothesized distribution if y is not provided. It can be one of "normal", "beta", "cauchy", "chisquare", "exponential", "f", "gamma", "lognormal", "logistic", "t", "uniform", "weibull", "binomial", "geometric", "hypergeometric", "negbinomial", "poisson", "wilcoxon". |
one-sample test | The Kolmogorov algorithm is used to get an exact p-value for every alternative. |
two-sample test | The Smirnov algorithm is used to get an exact p-value only for the two-sided alternative. |
statistic |
the KS statistic along with a names attribute that lists the statistic:
| ||||||
p.value | p-value for the test. | ||||||
alternative |
a character string that returns the alternative hypothesis
(two.sided, greater, or less) as specified in the alternative argument. For a one-sample test, the character string for each alternative hypothesis is:
| ||||||
method | a character string for the name of the method used for the calculation. | ||||||
data.name | a character string (vector of length 1) that contains the names of the x and y input vectors. |
# one sample z <- rnorm(100) ks.test(z, y = "pnorm") # hypothesize a normal distn. ks.test(z, y = "pchisq", df = 2) # hypothesize a chisquare distn. ks.test(z, y = "pgamma", shape = 3, scale = 2, exact = FALSE, alternative = "greater")# two sample x <- rnorm(90) y <- rnorm(8, mean = 2.0, sd = 1) ks.test(x, y) ks.test(x, y, exact = FALSE, alternative= "less")