[R] Jonckheere-Terpstra test
Marie Kraska
kraskmf at auburn.edu
Sat Mar 25 18:35:49 CET 2006
Hello, Can anyone tell me how to write the R script to get the P-value
for the Jonckheere-Terpstra (JT) test? Following is the code I am using.
I cannot get the P-value to print out. Any help would be appreciated.
Thanks. Marie
jt <- function(x, alpha=.05){
if(is.list(x) == 0) stop("Please enter a list of vectors.")
k <- length(x)
us <- matrix(0,k,k)
for(i in 1:(k-1)){
for(j in (i+1):k){
us[i,j] <- wilcox.test(x[[j]],
x[[i]])$statistic
}
}
sum(us)
}
con <- c(40,35,38,43,44,41)
gpb <- c(38,40,47,44,40,42)
gpc <- c(48,40,45,43,46,44)
jt(list(con,gpb,gpc))
More information about the R-help
mailing list