Skip to content

Instantly share code, notes, and snippets.

@abikoushi
Created June 4, 2024 12:12
Show Gist options
  • Save abikoushi/f97809258d807be2a3100ace029cdc8e to your computer and use it in GitHub Desktop.
Save abikoushi/f97809258d807be2a3100ace029cdc8e to your computer and use it in GitHub Desktop.
distribution of "signed rank" in Wilcoxon's test
library(ggplot2)
out <- vector("list", 10000)
for(i in 1:10000){
x <- rt(10,3)
out[[i]] <- sign(x)*rank(abs(x))
}
ggplot(data=NULL)+
geom_bar(aes(x=unlist(out), y=after_stat(count/sum(count))))+
theme_bw()+labs(x="signed ranked")
ggsave("symmetry_sr.png")
out2 <- vector("list", 10000)
for(i in 1:10000){
x <- rweibull(10,1.5) - log(2)^(1/1.5)
out2[[i]] <- sign(x)*rank(abs(x))
}
ggplot(data=NULL)+
geom_bar(aes(x=unlist(out2), y=after_stat(count/sum(count))))+
theme_bw()+labs(x="signed ranked")
ggsave("asymmetry_sr.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment