Hi! Any one knows how to obtain critical values for the k-s statistic, using R? Thanks, Alex -- View this message in context: http://r.789695.n4.nabble.com/kolmogorov-Smirnov-critical-values-tp4630245.html Sent from the R help mailing list archive at Nabble.com.
kolmogorov-Smirnov critical values
9 messages · Uwe Ligges, aramos, Petr Savicky +2 more
On Wed, May 16, 2012 at 9:52 AM, aramos <aramos at fep.up.pt> wrote:
Hi! Any one knows how to obtain critical values for the k-s statistic, using R?
Take a look at ?ks.test and the code of ks.test to see how R does it. OSS is super helpful for these sorts of things. Michael
Thanks, Alex -- View this message in context: http://r.789695.n4.nabble.com/kolmogorov-Smirnov-critical-values-tp4630245.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On 16.05.2012 15:52, aramos wrote:
Hi! Any one knows how to obtain critical values for the k-s statistic, using R?
ks.test(.....)$statistic Uwe ligges
Thanks, Alex -- View this message in context: http://r.789695.n4.nabble.com/kolmogorov-Smirnov-critical-values-tp4630245.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
I think that command will give me the statistics observed value!! Not quantiles from the k-s distribution! -- View this message in context: http://r.789695.n4.nabble.com/kolmogorov-Smirnov-critical-values-tp4630245p4630275.html Sent from the R help mailing list archive at Nabble.com.
Thanks, I've already done that!! What is OSS? -- View this message in context: http://r.789695.n4.nabble.com/kolmogorov-Smirnov-critical-values-tp4630245p4630276.html Sent from the R help mailing list archive at Nabble.com.
On Wed, May 16, 2012 at 06:52:48AM -0700, aramos wrote:
Hi! Any one knows how to obtain critical values for the k-s statistic, using R?
Hi.
I do not know, whether there is a function for this. However, the following
randomized approach allows to extract a table of statistic/p.value pairs
from ks.test() for fixed sample sizes.
n1 <- 30
n2 <- 50
d <- 10000
res <- matrix(nrow=d, ncol=2)
for (i in seq.int(length=d)) {
x1 <- runif(n1) + runif(1)
x2 <- runif(n2) + runif(1)
out <- ks.test(x1, x2)
res[i, 1] <- out$statistic
res[i, 2] <- out$p.value
}
tab <- unique(res[order(res[, 1]), ])
colnames(tab) <- c("statistic", "p.val")
If you are mainly interested in the range of the p-values for relatively
close distributions, then replace
x1 <- runif(n1) + runif(1)
x2 <- runif(n2) + runif(1)
by
x1 <- runif(n1)
x2 <- runif(n2)
Part of the obtained table is
statistic p.val
[39,] 0.30000000 5.642910e-02
[40,] 0.30666667 4.815638e-02
[41,] 0.31333333 4.091424e-02
[42,] 0.32000000 3.466530e-02
[43,] 0.32666667 2.925540e-02
[44,] 0.33333333 2.458672e-02
[45,] 0.34000000 2.060188e-02
[46,] 0.34666667 1.719140e-02
[47,] 0.35333333 1.428992e-02
[48,] 0.36000000 1.183727e-02
[49,] 0.36666667 9.767969e-03
Hope this helps.
Petr Savicky.
Open source software (what you're driving) Michael
On Wed, May 16, 2012 at 12:27 PM, aramos <aramos at fep.up.pt> wrote:
Thanks, I've already done that!! What is OSS? -- View this message in context: http://r.789695.n4.nabble.com/kolmogorov-Smirnov-critical-values-tp4630245p4630276.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On May 16, 2012, at 12:27 PM, aramos wrote:
Thanks, I've already done that!!
But the illustration for how you get the statistics is in the code. Describe what you want: number of samples, two versus single sided, two sample versus comparing to theory, which table columns should be used. Then someone can probably help.
-- View this message in context: http://r.789695.n4.nabble.com/kolmogorov-Smirnov-critical-values-tp4630245p4630276.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD West Hartford, CT
Thank you all for your help!! ! Alex -- View this message in context: http://r.789695.n4.nabble.com/kolmogorov-Smirnov-critical-values-tp4630245p4630393.html Sent from the R help mailing list archive at Nabble.com.