Random effects ANOVA?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Random effects ANOVA?

catsclaw
Hi all --

    So I have a very simple dataset, which consists of 60 subjects,
who watched one of three videos, drank one of two drinks, and
completed a task.  The response variable is the time to complete the
task.  The ANOVA command is simple enough:  anova(aov(time ~ drink *
video, data = df));

   However, the videos were randomly selected; I need to use the
random effects model for them.  So I tried anova(aov(time ~ drink +
Error(video), data = df));  This gives me a "no applicable method for
'anova'" error.

   The command aov works, but doesn't give me anything I can interpret
effectively.  Is there a simpler command I should be using?  Am I
doing something wrong?

-- Chris

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Random effects ANOVA?

Prof Brian Ripley
I think you want print or summary rather than anova.  anova() is not very
useful for aov() models even without error strata.  The point of the aov
classes is that they present the results of lm() fits in ways which are
more conventional for designed experiments, including giving conventional
ANOVA tables without recourse to anova().

I didn't follow how the videos were chosen.  Random effects apply when the
'treatments' were chosen from a large population (which might apply if
each subject watched (on separate occasions) three videos chosen randomly
from a larger pool), and if the interest is in the variability of the
response over videos in the pool.  If subjects were observed more than
once then I suspect you most likely want a random effect for subjects.

What I guess is more likely is that you have 60 measurements on 60
subjects, each of whom was assigned one video and one drink.  Then there
appear to be no random effects, and the problem caused by randomly
selecting videos is that the experiment is likely to be unbalanced (since
each video is not going to be selected 20 times by chance).  aov() is
primarily intended for balanced designs, and interpretation is tricky
without balance (see the warnings on its help page).

There are many loose ends hindering offering help by email, and the best
advice is to consult a statistician face-to-face about an appropriate
analysis.


On Wed, 29 Mar 2006, Chris Bergstresser wrote:

> Hi all --
>
>    So I have a very simple dataset, which consists of 60 subjects,
> who watched one of three videos, drank one of two drinks, and
> completed a task.  The response variable is the time to complete the
> task.  The ANOVA command is simple enough:  anova(aov(time ~ drink *
> video, data = df));
>
>   However, the videos were randomly selected; I need to use the
> random effects model for them.  So I tried anova(aov(time ~ drink +
> Error(video), data = df));  This gives me a "no applicable method for
> 'anova'" error.
>
>   The command aov works, but doesn't give me anything I can interpret
> effectively.  Is there a simpler command I should be using?  Am I
> doing something wrong?
>
> -- Chris

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Random effects ANOVA?

catsclaw
On 3/30/06, Prof Brian Ripley <[hidden email]> wrote:
> I think you want print or summary rather than anova.  anova() is not very
> useful for aov() models even without error strata.

    That's sort of better.  summary(aov(time ~ drink + Error(video),
data = df));

gives me:

Error: video
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  2    160      80

Error: Within
          Df  Sum Sq Mean Sq F value    Pr(>F)
drink      1 240.000 240.000  44.211 1.313e-08 ***
Residuals 56 304.000   5.429
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

...what I'm really looking for is something akin to the output from
SAS, which is:

Source     DF     Anova SS    Mean Square   F Value    Pr > F
DRINK       1      240.000        240.000     12.00    0.0742
VIDEO       2      160.000         80.000      4.00    0.2000

> I didn't follow how the videos were chosen.  Random effects apply when the
> 'treatments' were chosen from a large population (which might apply if
> each subject watched (on separate occasions) three videos chosen randomly
> from a larger pool), and if the interest is in the variability of the
> response over videos in the pool.  If subjects were observed more than
> once then I suspect you most likely want a random effect for subjects.

   This problem comes directly from the final for my Experimental
Stats class, which is why it feels a little odd.  The videos were
randomly selected from a library.  Subjects watched one of the three
videos, drank one of the two drinks, and completed the tasks.  There
were no repeated measures, so we can't block on subjects.
   The hypothesis test, according to SAS, treats DRINK*VIDEO as an
error term.  Setting aside whether this is the right analysis, how can
I replicate this analysis in R?

-- Chris

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Random effects ANOVA?

Peter Dalgaard
"Chris Bergstresser" <[hidden email]> writes:

> On 3/30/06, Prof Brian Ripley <[hidden email]> wrote:
> > I think you want print or summary rather than anova.  anova() is not very
> > useful for aov() models even without error strata.
>
>     That's sort of better.  summary(aov(time ~ drink + Error(video),
> data = df));
>
> gives me:
>
> Error: video
>           Df Sum Sq Mean Sq F value Pr(>F)
> Residuals  2    160      80
>
> Error: Within
>           Df  Sum Sq Mean Sq F value    Pr(>F)
> drink      1 240.000 240.000  44.211 1.313e-08 ***
> Residuals 56 304.000   5.429
> ---
> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>
> ...what I'm really looking for is something akin to the output from
> SAS, which is:
>
> Source     DF     Anova SS    Mean Square   F Value    Pr > F
> DRINK       1      240.000        240.000     12.00    0.0742
> VIDEO       2      160.000         80.000      4.00    0.2000
>
> > I didn't follow how the videos were chosen.  Random effects apply when the
> > 'treatments' were chosen from a large population (which might apply if
> > each subject watched (on separate occasions) three videos chosen randomly
> > from a larger pool), and if the interest is in the variability of the
> > response over videos in the pool.  If subjects were observed more than
> > once then I suspect you most likely want a random effect for subjects.
>
>    This problem comes directly from the final for my Experimental
> Stats class, which is why it feels a little odd.  The videos were
> randomly selected from a library.  Subjects watched one of the three
> videos, drank one of the two drinks, and completed the tasks.  There
> were no repeated measures, so we can't block on subjects.
>    The hypothesis test, according to SAS, treats DRINK*VIDEO as an
> error term.  Setting aside whether this is the right analysis, how can
> I replicate this analysis in R?

Possibly,

  time ~ drink + Error(video/drink)

It won't give you the F test for "video" though. Not quite sure
whether

  time ~ drink + video + Error(video:drink)

works. It might, although it is a bit unnatural to have a random
interaction between to systematic effects.


--
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - ([hidden email])                  FAX: (+45) 35327907

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Random effects ANOVA?

catsclaw
On 30 Mar 2006 22:41:51 +0200, Peter Dalgaard <[hidden email]> wrote:
>Not quite sure whether
>
>   time ~ drink + video + Error(video:drink)
>
> works. It might, although it is a bit unnatural to have a random
> interaction between to systematic effects.

   This exactly reproduces the given SAS output.  Whether it's
actually the right model to use, given the problem, is a different
question.  And luckily not one I have to answer.

-- Chris

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html