Learn R Programming

kolmim (version 1.0)

ks.test.imp: Kolmogorov-Smirnov Tests

Description

Perform a one-sample two-sided exact Kolmogorov-Smirnov test, similarly to ks.test from package stats, but using an improved routine.

Usage

ks.test.imp(x, y, ...)

Arguments

x
a numeric vector of data values.
y
either a numeric vector of data values, or a character string naming a cumulative distribution function or an actual cumulative distribution function such as pnorm. Only continuous CDFs are valid.
...
parameters of the distribution specified (as a character string) by y.

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
"two-sided".
method
a character string indicating what type of test was performed.
data.name
a character string giving the name(s) of the data.

Source

The two-sided one-sample distribution comes via Carvalho (2015).

Details

This routine is equivalent to ks.test(x, y, ..., exact=TRUE) but uses an improved method based on pkolmim. For more details about the arguments, please refer to the documentation for ks.test.

References

Luis Carvalho (2015), An Improved Evaluation of Kolmogorov's Distribution. Journal of Statistical Software, 65/3, 1--7. http://www.jstatsoft.org/v65/c03/.

See Also

pkolmim for the cumulative distribution function of Kolmogorov's goodness-of-fit measure.

Examples

Run this code
x <- abs(rnorm(100))
p.kt <- ks.test(x, "pexp", exact = TRUE)$p
p.ktimp <- ks.test.imp(x, "pexp")$p
abs(p.kt - p.ktimp)

# compare execution times
x <- abs(rnorm(2000))
system.time(ks.test.imp(x, "pexp"))
system.time(ks.test(x, "pexp", exact = TRUE))

Run the code above in your browser using DataLab