Created
June 4, 2024 08:30
-
-
Save abikoushi/ce24205c14fb4fd117ff7899d732453a to your computer and use it in GitHub Desktop.
Singed rank plot
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
signTable <- function(mu,x){ | |
x2 <- x-mu | |
x2 <- x2[x2 != 0] | |
data.frame(table(sign(x2)), loc=mu) | |
} | |
wilcoxTable <- function(mu,x){ | |
x2 <- x-mu | |
x2 <- x2[x2 != 0] | |
data.frame(w=sign(x2)*rank(abs(x2)), loc=mu) | |
} | |
x <- rt(30,5) + 1 | |
muv <- seq(min(x),max(x),by=0.1) | |
dfw <- bind_rows(lapply(muv, wilcoxTable, x=x)) | |
ggplot(dfw,aes(x=loc, y=w))+ | |
geom_tile(height=1, width=0.1, colour="lightgrey")+ | |
geom_vline(xintercept = 1, lty=1, colour="royalblue", alpha=0.7)+ | |
theme_bw()+ | |
labs(y="signed-rank", x = "location parameter (null)") | |
ggsave("wilcox.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment