Created
May 23, 2012 19:28
-
-
Save geofferyzh/2777245 to your computer and use it in GitHub Desktop.
RinAction - Nonparametric Test of Group Difference
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
######################################################## | |
######################################################## | |
# ---- Nonparametric tests of group differences ---- # | |
######################################################## | |
######################################################## | |
# NOTE: | |
# When you have more than 2 groups, you can use ANOVA or Nonparametric approaches | |
# to test group difference. ANOVA assumes data are independently sampled from normal | |
# populations. If the parametric assumptions are not met, nonparametric method can | |
# be used. | |
# Wilcoxon two group comparison | |
with(UScrime, by(Prob, So, median)) | |
wilcox.test(Prob ~ So, data=UScrime) | |
sapply(UScrime[c("U1", "U2")], median) | |
with(UScrime, wilcox.test(U1, U2, paired = TRUE)) | |
# Kruskal Wallis test | |
states <- as.data.frame(cbind(state.region, state.x77)) | |
kruskal.test(Illiteracy ~ state.region, data=states) | |
# Nonparametric multiple comparisons | |
class <- state.region | |
var <- state.x77[, c("Illiteracy")] | |
mydata <- as.data.frame(cbind(class, var)) | |
rm(class,var) | |
library(npmc) | |
summary(npmc(mydata), type = "BF") | |
aggregate(mydata, by = list(mydata$class), median) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment