p_ks.test {Spower} | R Documentation |
p-value from Kolmogorov-Smirnov one- or two-sample simulation
Description
Generates one or two sets of continuous data group-level data and returns a p-value under the null that the groups were drawn from the same distribution (two sample) or from a theoretically known distribution (one sample).
Usage
p_ks.test(n, p1, p2, n2_n1 = 1, two.tailed = TRUE, parent = NULL, ...)
Arguments
n |
sample size per group, assumed equal across groups |
p1 |
a function indicating how the data were generated for group 1 |
p2 |
(optional) a function indicating how the data were generated for group 2.
If omitted a one-sample test will be evaluated provided that |
n2_n1 |
sample size ratio. Default uses equal sample sizes |
two.tailed |
logical; should a two-tailed or one-tailed test be used? |
parent |
the cumulative distribution function to use
(e.g., |
... |
additional arguments to be passed to the
|
Value
a single p-value
Author(s)
Phil Chalmers rphilip.chalmers@gmail.com
See Also
Examples
# two-sample test from two Gaussian distributions with different locations
p1 <- function(n) rnorm(n)
p2 <- function(n) rnorm(n, mean=-.5)
p_ks.test(n=100, p1, p2)
# one-sample data from chi-squared distribution tested
# against a standard normal distribution
pc <- function(n, df=15) (rchisq(n, df=df) - df) / sqrt(2*df)
p_ks.test(n=100, p1=pc, parent=pnorm, mean=0, sd=1)
# empirical power estimates
p_ks.test(n=100, p1, p2) |> Spower()
p_ks.test(n=100, p1=pc, parent=pnorm, mean=0, sd=1) |> Spower()