Skip to content
Prev 65679 / 398506 Next

contrast matrix for aov

On Wed, 9 Mar 2005, Darren Weber wrote:

            
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?)
I think the error model should be Error(Subject).  In what sense are `Cue' 
and `Cue:Hemisphere' random effects nested inside `Subject'?

Let me fake some `data':

set.seed(1); roiValues <- rnorm(32)
subjectlabels <- paste("V"1:8, sep = "")
options(contrasts = c("contr.helmert", "contr.poly"))
roi.aov <- aov(roi ~ Cue*Hemisphere + Error(Subject), data=roiDataframe)
Call:
aov(formula = roi ~ Cue * Hemisphere + Error(Subject), data = roiDataframe)

Grand Mean: 0.1165512

Stratum 1: Subject

Terms:
                 Residuals
Sum of Squares   4.200946
Deg. of Freedom         7

Residual standard error: 0.7746839

Stratum 2: Within

Terms:
                       Cue Hemisphere Cue:Hemisphere Residuals
Sum of Squares   0.216453   0.019712       0.057860 21.896872
Deg. of Freedom         1          1              1        21

Residual standard error: 1.021131
Estimated effects are balanced

Note that all the action is in one stratum, and the SSQs are the same 
as

aov(roi ~ Subject + Cue * Hemisphere, data = roiDataframe)

(and also the same as for your fit).
It auto-prints, so you don't need print().
(That is up to sign what Helmert contrasts give you.)
Yes, as however you code the design (via `contrasts') you are fitting the 
same subspaces.  Not sure what you mean by `contrast direction', though.

However, you have not specified `contrasts' correctly:

contrasts: A list of contrasts to be used for some of the factors in
           the formula.

and cm is not a list, and an interaction is not a factor.
For more than two levels, yes: see `split' under ?summary.aov.
Also, see se.contrasts which allows you to find the standard error for any 
contrast.

For the fixed-effects model you can use summary.lm:
Df  Sum Sq Mean Sq F value Pr(>F)
Subject         7  4.2009  0.6001  0.5756 0.7677
Cue             1  0.2165  0.2165  0.2076 0.6533
Hemisphere      1  0.0197  0.0197  0.0189 0.8920
Cue:Hemisphere  1  0.0579  0.0579  0.0555 0.8161
Residuals      21 21.8969  1.0427
Call:
aov(formula = roi ~ Subject + Cue * Hemisphere, data = roiDataframe)

Residuals:
     Min      1Q  Median      3Q     Max
-1.7893 -0.4197  0.1723  0.5868  1.3033

Coefficients:
                  Estimate Std. Error t value Pr(>|t|)
[...]
Cue1             -0.08224    0.18051  -0.456    0.653
Hemisphere1       0.02482    0.18051   0.137    0.892
Cue1:Hemisphere1 -0.04252    0.18051  -0.236    0.816

where the F values are the squares of the t values.