Nothing
set.seed(1) knitr::opts_chunk$set(echo = TRUE) library("hyper2")
![](`r system.file("help/figures/hyper2.png", package = "hyper2")`){width=10%}
We do some work with Mann-Whitney test, using the chorioamnion dataset at wilcox.test.Rd
:
x <- c(0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46) y <- c(1.15, 0.88, 0.90, 0.74, 1.21)
First do the Mann-Whitney-Wilcox test:
wilcox.test(x,y)
Now use hyper3
:
names(x) <- rep("x",length(x)) names(y) <- rep("y",length(y)) equalp.test(ordervec2supp3(names(sort(c(x,y)))))
n <- 100 a <- matrix(0,n,2) colnames(a) <- c("mww","hyper3") for(i in seq_len(n)){ d <- rrace3(pn=c(a=10,b=10),ps=c(a=0.5,b=0.5)) #null jj <- seq_along(d) a[i,1] <- wilcox.test(jj[d=="a"],jj[d=="b"])$p.value a[i,2] <- equalp.test(ordervec2supp3(d))$p.value }
head(a) par(pty="s") plot(log10(a),asp=1,xlim=c(-2,0),ylim=c(-2,0),main="p-values under the NULL (log scale)", xlab="log(p),Wilcox",ylab="log(p), hyper3") abline(0,1) plot(a,asp=1,xlim=c(0,1),ylim=c(0,1),main="p-values under the NULL (linear scale)",xlab="p,Wilcox",ylab="p,hyper3") abline(0,1) (size_wilcox <- sum(a[,1]<0.05)/nrow(a)) (size_hyper3 <- sum(a[,2]<0.05)/nrow(a)) table(type_I_wilcox=a[,1]<0.05,type_I_hyper3=a[,2]<0.05)
n <- 100 a <- matrix(0,n,2) colnames(a) <- c("mww","hyper3") for(i in seq_len(n)){ d <- rrace3(pn=c(a=10,b=10),ps=c(a=0.2,b=0.8)) jj <- seq_along(d) a[i,1] <- wilcox.test(jj[d=="a"],jj[d=="b"])$p.value a[i,2] <- equalp.test(ordervec2supp3(d))$p.value }
head(a) par(pty="s") plot(log10(a),asp=1,xlim=c(-4,0),ylim=c(-4,0)) abline(0,1) (power_wilcox <- sum(a[,1]<0.05)/nrow(a)) (power_hyper3 <- sum(a[,2]<0.05)/nrow(a)) table(wilcox=a[,1]<0.05,hyper3=a[,2]<0.05)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.