Created
August 13, 2014 18:47
-
-
Save kbroman/0f7c9b055b5694abf66e to your computer and use it in GitHub Desktop.
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
| # 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 | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Brief simulation to compare p-values from anova with ranks and kruskal-wallis test.