[R] Order of terms in formula changes aov() results

David Winsemius dwinsemius at comcast.net
Fri Mar 23 17:28:27 CET 2012


On Mar 22, 2012, at 5:06 PM, Stuart Luppescu wrote:

> Hello, This one is very perplexing. I have teacher observation data,
> with factors teacher ID, observer ID, component, grade and subject.  
> When
> I do this,
>
> aov(data=ratings.prin.22, rating ~ obsid.f + tid.f + subject.f +  
> grade.f + comp.f)
>
> I get this:
>
> Terms:
>                  obsid.f     tid.f   grade.f    comp.f Residuals
> Sum of Squares  306.23399 221.38173   1.70000  14.52831 279.05780
> Deg. of Freedom        74        87         2         9      1406
>
> This looks right.

  What about the missing SS for subject.f?

> There are about 82 observers so 74 degrees of freedom
> for obsid.f is OK. But if I do this (just reordering the terms in the
> formula):
>
> aov(data=ratings.prin.22, rating ~ comp.f + grade.f + subject.f +  
> tid.f + obsid.f)
>
> I get this:
>
> Terms:
>                  comp.f  grade.f subject.f    tid.f  obsid.f Residuals
> Sum of Squares   15.0923  23.3968    5.9982 499.3568   0.0000   
> 279.0578
> Deg. of Freedom        9        4         4      152        3       
> 1406
>
> Now obsid.f only has 3 degrees of freedom and the sum of squares is
> 0.00. Could this be due to the unbalanced design?

I would have guessed collinearity.

>
> If someone can explain this to me I would be very grateful.
>
> -- 
> Stuart Luppescu -=- slu .at. ccsr.uchicago.edu


David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list