1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
R Under development (unstable) (2013-09-01 r63796) -- "Unsuffered Consequences"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
>
> library("maxstat")
> library("exactRankTests")
Loading required package: survival
Loading required package: splines
Package 'exactRankTests' is no longer under development.
Please consider using package 'coin' instead.
> set.seed(290875)
>
> # by Achim Zeileis, 13.09.2002
> y <- c(0.9, 1, 0.8, 0.8, 0.85, 0.3, 0.2, 0.2, 0.1, 0.2, 0.3)
> index <- 1:length(y)
> mydata <- data.frame(cbind(y, index))
> maxstat.test(y ~ index, data=mydata, smethod = "Wilcoxon", pmethod = "HL")
Maximally selected Wilcoxon statistics using HL
data: y by index
M = 2.7767, p-value < 2.2e-16
sample estimates:
estimated cutpoint
5
> # this one failed: QUANT not known
> maxstat.test(y ~ index, data=mydata)
Maximally selected Wilcoxon statistics using none
data: y by index
M = 2.7767, p-value = NA
sample estimates:
estimated cutpoint
5
>
> # spotted and fixed 16.09.2002
> y <- rnorm(20)
> x <- factor(c(rep(0,10), rep(1,10)))
> mydata <- data.frame(cbind(y,x))
> a <- maxstat.test(y ~ x, data=mydata, smethod="Wilcoxon", pmethod="HL")
> b <- wilcox.exact(y ~ x, data=mydata)
> stopifnot(all.equal(a$p.value, b$p.value))
>
> # check new conditional Monte-Carlo p-values
>
> set.seed(290875)
> a <- maxstat.test(y ~ x, data=mydata, smethod="Wilcoxon", pmethod="condMC",
+ B = 9999)$p.value
> a
[1] 0.9150915
> set.seed(290875)
> b <- maxstat.test(y ~ x, data=mydata, smethod="Wilcoxon", pmethod="condMC",
+ B = 9999, alpha = 0.9)$p.value
> b
[1] 0.9150915
> stopifnot(all.equal(a, b))
>
>
> proc.time()
user system elapsed
0.192 0.036 0.223
|