[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-help
Subject:    [R] box correction or Huynh-Feldt epsilon
From:       John Christie <jc () or ! psychology ! dal ! ca>
Date:       2003-12-16 15:04:07
[Download RAW message or body]

Following up the several unanswered requests for a sphericity or 
circularity test in the archives, those who wish to test should feel 
free to use the following function.  If anyone notices errors please 
correct.  The returned value is an epsilon one can use to correct 
degrees of freedom.  It is less conservative than the 
Greenhouse-Geisser I believe.

# 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
}

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic