[R] contrast matrix for aov

Darren Weber DarrenLeeWeber at gmail.com
Thu Mar 10 20:07:44 CET 2005


As an R newbie (formerly SPSS), I was pleased to find some helpful notes 
on ANOVA here:

http://personality-project.org/r/r.anova.html

In my case, I believe the relevant section is:

Example 4. Two-Way Within-Subjects ANOVA

This is where I noted and copied the error notation.

Sorry for any confusion about terms - I did mean "within-subjects" 
factors, rather than repeated measures (although, as noted earlier, we 
do have both in this experiment).


Prof Brian Ripley wrote:

> On Thu, 10 Mar 2005, Christophe Pallier wrote:
>
>>
>> Prof Brian Ripley wrote:
>>
>>>> On Wed, 9 Mar 2005, Darren Weber wrote:
>>>>
>>>> We have a two-factor, repeated measures design, with
>>>
>>>
>>>
>>> Where does `repeated measures' come into this?  You appear to have 
>>> repeated a 2x2 experiment in each of 8 blocks (subjects).  Such a 
>>> design is usually analysed with fixed effects.  (Perhaps you 
>>> averaged over repeats in the first few lines of your code?)
>>>
>>>>
>>>> roi.aov <- aov(roi ~ (Cue*Hemisphere) + 
>>>> Error(Subject/(Cue*Hemisphere)), data=roiDataframe)
>>>
>>>
>>>
>>> I think the error model should be Error(Subject).  In what sense are 
>>> `Cue' and `Cue:Hemisphere' random effects nested inside `Subject'?
>>>
>>
>> I do not understand this, and I think I am probably not the only one. 
>> That is why I would be grateful if you could give a bit more 
>> information.
>>
>> My understanding is that the fixed factors Cue and Hemisphere are 
>> crossed with the random factor Subject (in other words, Cue and 
>> Hemisphere are within-subjects factors, and this is probably why 
>> Darren called it a "repeated measure" design).
>
>
> The issue is whether the variance of the error really depends on the 
> treatment combination, which is what the 
> Error(Subject/(Cue*Hemisphere)) assumes.  With that model
>
> Error: Subject:Cue
>           Df Sum Sq Mean Sq F value Pr(>F)
> Cue        1 0.2165  0.2165  0.1967 0.6708
> Residuals  7 7.7041  1.1006
>
> Error: Subject:Hemisphere
>            Df Sum Sq Mean Sq F value Pr(>F)
> Hemisphere  1 0.0197  0.0197  0.0154 0.9047
> Residuals   7 8.9561  1.2794
>
> Error: Subject:Cue:Hemisphere
>                Df Sum Sq Mean Sq F value Pr(>F)
> Cue:Hemisphere  1 0.0579  0.0579  0.0773  0.789
> Residuals       7 5.2366  0.7481
>
> you are assuming different variances for three contrasts.
>
>> In this case, it seems to me from the various textbooks I read on 
>> Anova, that the appropriate MS to  test the interaction 
>> Cue:Hemisphere is Subject:Cue:Hemisphere (with 7 degress of freedom, 
>> as there are 8 independent subjects). If you input 
>> Error(Subject/(Cue*Hemisphere)) in the aov formula, then the test for 
>> the interaction indeed uses the Subject:Cue:Hemisphere source of 
>> variation in demoninator. This fits with the ouput of other softwares.
>>
>> If you include only 'Subjet', then the test for the interaction has 
>> 21 degrees of Freedom, and I do not understand what this tests.
>
>
> It uses a common variance for all treatment combinations.
>
>> I apologize in if my terminology is not accurate.  But I hope you can 
>> clarify what is wrong with the Error(Subject/(Cue*Hemisphere)) term,
>> or maybe just point us to the relevant textbooks.
>
>
> Nothing is `wrong' with it, it just seems discordant with the description
> of the experiment.
>




More information about the R-help mailing list