Rev 15168 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{ks.test}\alias{ks.test}\title{Kolmogorov-Smirnov Tests}\description{Performs one or two sample Kolmogorov-Smirnov tests.}\usage{ks.test(x, y, \dots, alternative = c("two.sided", "less", "greater"),exact = NULL)}\arguments{\item{x}{a numeric vector of data values.}\item{y}{either a numeric vector of data values, or a character stringnaming a distribution function.}\item{\dots}{parameters of the distribution specified by \code{y}.}\item{alternative}{indicates the alternative hypothesis and must beone of \code{"two.sided"} (default), \code{"less"}, or\code{"greater"}. You can specify just the initial letter.}\item{exact}{\code{NULL} or a logical indicating whether an exactp-value should be computed. See Details for the meaning of \code{NULL}.Only used in the two-sided two-sample case.}}\details{If \code{y} is numeric, a two-sample test of the null hypothesisthat \code{x} and \code{y} were drawn from the same \emph{continuous}distribution is performed.Alternatively, \code{y} can be a character string naming a continuousdistribution function. In this case, a one sample test of the nullthat the distribution function underlying \code{x} is \code{y} withparameters specified by \code{\dots} is carried out.The presence of ties generates a warning, since continuous distributionsdo not generate them.The possible values \code{"two.sided"}, \code{"less"} and\code{"greater"} of \code{alternative} specify the null hypothesisthat the true distribution function of \code{x} is equal to, not lessthan or not greater than the hypothesized distribution function(one-sample case) or the distribution function of \code{y} (two-samplecase), respectively.Exact p-values are only available for the two-sided two-sample testwith no ties. In that case, if \code{exact = NULL} (the default) anexact p-value is computed if the product of the sample sizes is lessthan 10000. Otherwise, asymptotic distributions are used whoseapproximations may be inaccurate in small samples.}\value{A list with class \code{"htest"} containing the following components:\item{statistic}{the value of the test statistic.}\item{p.value}{the p-value of the test.}\item{alternative}{a character string describing the alternativehypothesis.}\item{method}{a character string indicating what type of test wasperformed.}\item{data.name}{a character string giving the name(s) of the data.}}\references{Conover, W. J. (1971),\emph{Practical nonparametric statistics}.New York: John Wiley & Sons.Pages 295--301 (one-sample ``Kolmogorov'' test),309--314 (two-sample ``Smirnov'' test).}\seealso{\code{\link{shapiro.test}} which performs the Shapiro-Wilk test fornormality.}\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-sidedks.test(x+2, "pgamma", 3, 2, alternative = "gr")}\keyword{htest}