[Rd] Re: [R] H-F corr.: covariance matrix for interaction effect

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Feb 25 01:48:33 CET 2005


Peter Dalgaard <p.dalgaard at biostat.ku.dk> writes:

> Bela Bauer <bela_b at gmx.net> writes:
> 
> > Hi,
> > 
> > I'm still not quite there with my H-F (G-G) correction code. I have it
> > working for the main effects, but I just can't figure out how to do it
> > for the effect interactions. The thing I really don't know (and can't
> > find anything about) is how to calculate the covariance matrix for the
> > interaction between the two (or even n) main factors.
> > I've looked through some books here and I've tried everything that came
> > to my mind, but I can't seem to be able to figure out an algorithm that
> > does it for me.
> > 
> > Could anyone give me a hint about how I could do this?
> > (I'll append my code at the end, in case that helps in any way...)
> 
> I have given it to you before: My plan is to drop the explicit formula
> involving on/off diagonal elements of S and go directly at Box (1954),
> theorems 3.1 and 6.1, involving eigenvalues of TST', where T is the
> relevant residual operator. In the case where one of the factors have
> only two levels, I believe you just take differences and use the usual
> formula, but more than two levels is tricky.

[moved to r-devel since this is getting technical]

Now I am getting confused: I can reproduce the G-G epsilon in all the
cases I have tried but the H-F epsilon eludes me. Consider this SAS
code

proc glm;
        model bmc1-bmc7=  / nouni;
        repeated visit 7/printe;

This ends up with

                      Greenhouse-Geisser Epsilon    0.6047
                      Huynh-Feldt Epsilon           0.7466

This makes OK sense since there are 22 observations

> (22*6*0.6047 -2)/(6*(21-6*.6047))
[1] 0.7466162

However, consider the following small change:

proc glm;
        class grp;
        model bmc1-bmc7= grp / nouni;
        repeated visit 7/printe;

Now I get 

                      Greenhouse-Geisser Epsilon    0.6677
                      Huynh-Feldt Epsilon           0.8976

Since we have one less DF for the covariance matrix, I would expect
that the H-F epsilon would be

> (21*6*0.6677)/(6*(20-6*.6677))
[1] 0.876696

The discrepancy gets worse as more covariates are added. If bmc1 is
moved to the rhs, I get

                      Greenhouse-Geisser Epsilon    0.6917
                      Huynh-Feldt Epsilon           0.9533

Where I would have expected

> (20*5*0.6917-2)/(5*(19-5*.6917))
[1] 0.8643953

Does anyone have a clue as to what is going on here? Is mighty SAS
simply doing the wrong thing? The G-G epsilon depends only on the
eigenvalues of the observed covariance matrix, so surely the H-F
correction should depend only on the dimension and the DF for the
empirical covariance matrix? 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907



More information about the R-devel mailing list