Dear All,
I tried to help myself by searching in newsgroups etc. I found a test for
epsilon in a newsgroup (see attachement). I wrote a little skript to update
the summary.anova if epsilon < 0.75.
Although I doublechecked my statistic book for the formula, the result is
always the half of the epsilon calculated by SPSS. It is really strange. If I
multiply espilon by two, I get the right results...
regards,
WP
#------------------------------------begin -----------------------------
correctSummary <- function(sum,eps) {
# eps is the epsilon-value returned by function "hf"
# sum is the summary.aov object in which the Huynh-Fldt correction has to be
down
len <- length(sum)
newSum <- sum
for (i in 2: len) {
newSum[[i]][[1]][4,] <- newSum[[i]][[1]][2,]
newSum[[i]][[1]][3,] <- newSum[[i]][[1]][2,]
newSum[[i]][[1]][2,] <- newSum[[i]][[1]][1,]
rownames(newSum[[i]][[1]]) <- c(rownames(newSum[[i]][[1]][1,]),
"Huynh-Feldt", rownames(newSum[[i]][[1]][2,]),
"Huynh-Feldt")
newSum[[i]][[1]][2,][1] <- newSum[[i]][[1]][2,][1]*epsilon*2
newSum[[i]][[1]][4,][1] <- newSum[[i]][[1]][4,][1]*epsilon*2
newSum[[i]][[1]][2,][3] <- newSum[[i]][[1]][2,][2]/newSum[[i]][[1]][2,][1]
newSum[[i]][[1]][4,][3] <- newSum[[i]][[1]][4,][2]/newSum[[i]][[1]][4,][1]
newSum[[i]][[1]][2,][4] <- newSum[[i]][[1]][2,][3]/newSum[[i]][[1]][4,][3]
newSum[[i]][[1]][2,][5] <- pf(as.numeric(newSum[[i]][[1]][2,][4]),
as.numeric(newSum[[i]][[1]][2,][1]), as.numeric(newSum[[i]][[1]][4,][1]),
lower.tail = FALSE)
}
newSum
}
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)
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 <- (1/(J-1))*((J^2*(D-SPm)^2)/(SPm2 - 2*J*SSrm + J^2*SPm^2))
epsilon
}
# ----------------------------------------------------------------------------
On Thursday December 18 2003 12:00, Wolfgang Pauli
wrote:> Dear R-helpers,
>
> Does anybody know, whether there is an option to tell aov/anova, or do
> something similar, to get a Huynh-Feldt correction of dfs in the aov/anova
> function?
>
> Thanks in advance!
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help