[R] Random effects ANOVA

2006-11-24 Thread Luis Salasar
Hi,

I used the command lmer, in package lme4, to fit a random effects ANOVA. But i 
didn't get the p-values of significance tests of variance components. Does 
anyone know how  to do it? Thanks,

Luis Ernesto


-

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Random effects ANOVA

2006-11-24 Thread John Fox
Dear Luis,

I believe that lmer() doesn't print out standard errors or Wald tests for
variance-covariance components because these tests aren't reliable. You can
omit each random effect from the model in turn, and use anova() to perform a
likelihood-ratio test for the corresponding variance and covariance
components, comparing each null model with the full model.

I hope this helps,
 John


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Luis Salasar
 Sent: Friday, November 24, 2006 1:57 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Random effects ANOVA
 
 Hi,
 
 I used the command lmer, in package lme4, to fit a random 
 effects ANOVA. But i didn't get the p-values of significance 
 tests of variance components. Does anyone know how  to do it? Thanks,
 
 Luis Ernesto
 
   
 -
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Random effects ANOVA?

2006-03-30 Thread Chris Bergstresser
On 3/30/06, Prof Brian Ripley [EMAIL PROTECTED] 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  2160  80

Error: Within
  Df  Sum Sq Mean Sq F valuePr(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 SSMean Square   F ValuePr  F
DRINK   1  240.000240.000 12.000.0742
VIDEO   2  160.000 80.000  4.000.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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Random effects ANOVA?

2006-03-30 Thread Peter Dalgaard
Chris Bergstresser [EMAIL PROTECTED] writes:

 On 3/30/06, Prof Brian Ripley [EMAIL PROTECTED] 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  2160  80
 
 Error: Within
   Df  Sum Sq Mean Sq F valuePr(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 SSMean Square   F ValuePr  F
 DRINK   1  240.000240.000 12.000.0742
 VIDEO   2  160.000 80.000  4.000.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
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Random effects ANOVA?

2006-03-30 Thread Chris Bergstresser
On 30 Mar 2006 22:41:51 +0200, Peter Dalgaard [EMAIL PROTECTED] 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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Random effects ANOVA?

2006-03-29 Thread Chris Bergstresser
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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Random effects ANOVA?

2006-03-29 Thread 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,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html