Skip to content

Instantly share code, notes, and snippets.

@kbroman
Created August 13, 2014 18:47
Show Gist options
  • Select an option

  • Save kbroman/0f7c9b055b5694abf66e to your computer and use it in GitHub Desktop.

Select an option

Save kbroman/0f7c9b055b5694abf66e to your computer and use it in GitHub Desktop.
# simulate some data and run anova with ranks + Kruskal-Wallis
k <- sample(1:3, 100, repl=TRUE)
eff <- (1:10)/10
pval <- matrix(nrow=length(eff), ncol=2)
dimnames(pval) <- list(as.character(eff), c("anova", "k-w"))
for(i in seq(along=eff)) {
y <- k*eff[i] + rt(length(k), 3) # residuals ~ t(df=3)
pval[i,1] <- anova(lm(rank(y) ~ factor(k)))[1,5]
pval[i,2] <- kruskal.test(y ~ factor(k))$p.value
}
@kbroman

kbroman commented Aug 13, 2014

Copy link
Copy Markdown
Author

Brief simulation to compare p-values from anova with ranks and kruskal-wallis test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment