# Welsh test by permutations

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**[R] tricks**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

WelshPerm <- function(response,variable,nperm=999,...){ base <- oneway.test(response~variable,...) base.p <- base$p.value base.W <- base$statistic count <- 1 # Permutation loop for(i in 1:nperm){ SAMPLE <- sample(response) welsh.perm<-oneway.test(SAMPLE~variable,...) welsh.perm.p<-welsh.perm$p.value welsh.perm.W<-welsh.perm$statistic if(abs(welsh.perm.W) >= abs(base.W)) {count <- count+1} } result=count/(nperm+1) return(result) }

To

**leave a comment**for the author, please follow the link and comment on their blog:**[R] tricks**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.