Created
August 26, 2024 09:25
-
-
Save abikoushi/395c6b7daf25bf6396232e730eca7c80 to your computer and use it in GitHub Desktop.
An simulation of wilcox.test for the compositional data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(gtools) | |
| library(ggplot2) | |
| library(ggbrick) | |
| set.seed(1) | |
| wp <- numeric(10000) | |
| ksp <- numeric(10000) | |
| tp <- numeric(10000) | |
| for(i in 1:10000){ | |
| y1 <- rdirichlet(50,rep(1,10)) | |
| y2 <- rdirichlet(50,rep(10,10)) | |
| wp[i] <- wilcox.test(y1[,1],y2[,1])$p.value | |
| ksp[i] <- ks.test(y1[,1],y2[,1])$p.value | |
| tp[i] <- t.test(y1[,1],y2[,1])$p.value | |
| } | |
| hist(ksp,main="ks.test",xlab = "p-value") | |
| hist(tp,main="t.test",xlab = "p-value") | |
| hist(wp,main="wilcox.test",xlab = "p-value") | |
| df <- data.frame(x=rep(LETTERS[1:2],each=50),y=c(y1,y2)) | |
| ggplot(df,aes(x=x,y=y))+ | |
| geom_brick()+ | |
| theme_bw() | |
| ggplot(df,aes(x=x,y=y))+ | |
| stat_summary(fun.y="mean",geom="col",alpha=0.8)+ | |
| stat_summary(geom = "errorbar",width=0.5)+ | |
| theme_bw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment