[R] How to get Greenhouse-Geisser epsilons from anova?
p.dalgaard at biostat.ku.dk
Sat Dec 6 00:09:32 CET 2008
> Dear Mr. Daalgard.
> thank you very much for your reply, it helped me to progress a bit.
> The following works fine:
> dd <- expand.grid(C = 1:7, B= c("r", "l"), A= c("c", "f"))
> myma <- as.matrix(myma) #myma is a 12 by 28 list
> mlmfit <- lm(myma~1)
> mlmfit0 <- update(mlmfit, ~0)
> anova(mlmfit, mlmfit0, X= ~C+B, M = ~A+C+B, idata = dd,
> test="Spherical"), which tests the main effect of A.
> anova(mlmfit, mlmfit0, X= ~A+C, M = ~A+C+B, idata = dd,
> test="Spherical"), which tests the main effect of B.
> However, I can not figure out how this works for the other effects.
> If I try:
> anova(mlmfit, mlmfit0, X= ~A+B, M = ~A+C+B, idata = dd, test="Spherical")
> I get:
> Fehler in function (object, ..., test = c("Pillai", "Wilks",
> "Hotelling-Lawley", :
> residuals have rank 1 < 4
dd$C is not a factor with that construction. It works for me after
dd$C <- factor(dd$C)
(The other message is nasty, though. It's slightly different in R-patched:
> anova(mlmfit, mlmfit0, X= ~A+B, M = ~A+C+B, idata = dd,
Error in solve.default(Psi, B) :
system is computationally singular: reciprocal condition number =
but it shouldn't happen...
Looks like it is a failure of the internal Thin.row function. Ick!
> I also don't know how I can calculate the various interactions..
> My read is I should change the second argument mlmfit0, too, but I can't
> figure out how...
The "within" interactions should be straightforward, e.g.
The within/between interactions are otained from the similar tests of
the between factor(s)
mlmfitD <- lm(myma~D)
> Do you know what to do?
> Thank you very much!
> Peter Dalgaard schrieb:
>> Skotara wrote:
>>> Dear all,
>>> I apologize for my basic question.
>>> I try to calculate an anova for repeated measurements with 3 factors
>>> (A,B,C) having 2, 2, and 7 levels.
>>> or with an additional fourth between subjects factor D.
>>> Everything works fine using
>>> aov(val ~ A*B*C + Error(subject/ (A*B*C) ) ) or
>>> aov(val ~ (D*A*B*C) + Error(subject/(A*B*C)) + D )
>>> val, A, B, C, D and subject are columns in a data.frame.
>>> How can I get the estimated Greenhouse-Geisser and Huynh-Feldt epsilons?
>>> I know Peter Dalgaard described it in R-News Vol. 7/2, October 2007.
>>> However, unfortunately I am not able to apply that using my data...
>> Why? It is supposed to work. You just need to work out the X and M
>> specification for the relevant error strata and set test="Spherical"
>> for anova.mlm, or work out the T contrast matrix explicitly if that
>> suits your temper better.
>>> Furthermore, I am still confused of how SPSS calculates the epsilons
>>> since it is mentioned that perhaps there are any errors in SPSS??
>>> I would be glad if anyone could help me!
>>> I am looking forward to hearing from you!
>>> Thank you!
>>> R-help at r-project.org mailing list
>>> PLEASE do read the posting guide
>>> and provide commented, minimal, self-contained, reproducible code.
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help