[R] test h-f sphericity test?
John Christie
jc at or.psychology.dal.ca
Wed Dec 24 01:40:48 CET 2003
I posted some R code that could be an h-f sphericity test. Is there
anyone out there with SPSS, Systat, or some other package that has a
built in test who can verify whether it is accurate or not?
John
(here is the code again)
# This returns the Huynh-Feldt or "Box Correction" for degrees of
freedom
hf <- function(m){
# m is a matrix with subjects as rows and conditions as columns
# note that checking for worst case scenarios F correction first might
# be a good idea using J/(J-1) as the df correction factor
n<- length(m[,1])
J<-length(m[1,])
X<-cov(m)*(n-1)
r<- length(X[,1])
D<-0
for (i in 1: r) D<- D+ X[i,i]
D<-D/r
SPm<- mean(X)
SPm2<- sum(X^2)
SSrm<-0
for (i in 1: r) SSrm<- SSrm + mean(X[i,])^2
epsilon<- (J^2*(D-SPm)^2) / ((J-1) * (SPm2 - 2*J*SSrm + J^2*SPm^2))
epsilon
}
More information about the R-help
mailing list