[R] aov for mixed model (fixed and random)?

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Wed Dec 26 18:26:03 CET 2001

baron at cattell.psych.upenn.edu (Jonathan Baron) writes:

> The answer that works:
> aov2 <- aov( hl ~ task +Error(subject/task) )
> summary(aov2)

It doesn't, but aov2 <- aov( h1 ~ task +Error(subj/task) )

> yields the correct F test for task.  Presumably this is because
> task is a within-subject variable, so task is "nested" (I guess
> that is the term) within subject.

The advice from the good ol' Genstat manual was to consider the error
model a thing in itself, separate from the fixed effects. So you're
having  a model in which there are different means for each task, and
on top of that you add random effects from three sources

(a) subj: add i.i.d terms that are common for all measurements on
the same subject.

(b) subj:task add i.i.d terms that are common for all measurements on
the same combination of task and subject. 

(c) residual: i.i.d terms different for all measurements

The interpretation of (b) is the tricky bit. You can either take it to
mean that subjects really do respond differently to different tasks,
and that that variation is what you model, or more simply as an
indication that the replications on each subj:task combination are
correlated, e.g. because they are insufficiently separated in time.

> But ...
> 1. It does not work with anova(aov2), just with summary(aov2).

Why should it? summary() gives the correctly stratified ANOVA table.
anova() doesn't know how to deal with objects of class "aovlist".

> 2. I still can't figure out how to get get this to give the
>    interaction effect.

It's the residual MS in the subj:task stratum. You don't get the 
test for it though. In this particular case, it is trivial to
calculate as F = MSres(subj:task)/MSres(Within), but with other
designs it is not so simple (notably when you have both row and column
random effects) so you have to know what you are doing.

   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
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list