By accident, I left out the lines defining n1 and n2. Here it is as a
function.
Peter B.
hotelling <- function(d1,d2){
k <- ncol(d1)
n1 <- nrow(d1)
n2 <- nrow(d2)
xbar1 <- apply(d1,2,mean)
xbar2 <- apply(d2,2,mean)
dbar <- xbar2-xbar1
v <- ((n1-1)*var(d1)+(n2-1)*var(d2))/(n1+n2-2)
t2 <- n1*n2*dbar%*%solve(v)%*%dbar/(n1+n2)
f <- (n1+n2-k-1)*t2/((n1+n2-2)*k)
cat("F:",f,"\n")
cat("PROBABILITY:",1-pf(f,k,n1+n2-k-1),"\n")
}
> source("c:/r/hotell3")
> d1 <- read.table("c:/r/a.dat")
> d2 <- read.table("c:/r/b.dat")
> hotelling(d1,d2)
F: 1.797264
PROBABILITY: 0.1575505
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._