line <- rep(1:3,rep(10,3))
defects <- c(6,38,3,17,11,30,15,16,25,5,34,28,42,13,40,31,9,32,39,27,13,35,19,4,29,0,7,33,18,24)
R <- rank(defects)
defect <- data.frame(line, defects, R)
# rank sum of each group
S <- tapply(defect$R,defect$line,sum)
# sample size of each group
ni <- table(defect$line)
# total sample size
n <- sum(ni)
# number of groups
k <- length(unique(line))
# test statistic
H <- 12/(n*(n+1))*sum(S^2/ni) - 3*(n+1)
# p-value
pvalue <- 1-pchisq(H, k-1)
### R function
kruskal.test(defects~line, data=defect)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment