[R] How to test for a random effect in a repeated measures analysis using anova.mlm ?

marie-lou.lefrancois at bvcentre.ca marie-lou.lefrancois at bvcentre.ca
Wed Aug 13 19:40:36 CEST 2008


Dear “R” masters,

I am trying to conduct an ANOVA with repeated measures using the command
anova.mlm for data structured according to a Randomized Block Design.
I would like to account for a random effect but cannot find a way to
incorporate it in the analysis.

NB. I tried using the argument “M” to define the outer projection
(block), I get the message that length differs.

“response” is the dependent variable (3 years of heights measurements,
merged with cbind).

“estab” is a factor with 3 levels (whether trees were planted, seeded
or naturally established).

I would like to include “block” as a random effect. I would like to
keep the structure of the response variable (so I don’t get an output
with a test for each year: this is what happens when I use “lme” or
“aov”).

This is the code I am using:
First, fit linear models:
estabfit<-lm(response~estab)

 timefit<-lm(response~1)
 
Then test the effect of the factor “estab”
 anova.mlm(timefit,estabfit,M=~1).

How do I integrate “block”?

I was inspired by: http://tolstoy.newcastle.edu.au/R/help/05/11/15744.html

Thank you so much for your help!
Cheers
Marie-lou Lefrancois



More information about the R-help mailing list