I want to specify two factors and their interaction as random effects using
the function lme().   This works okay when I specify these terms using the
function Error() within the function aov(), but I can't get the same model
fitted using lme().   The code below illustrates the problem.

 

a <- factor(rep(c(1:3), each = 27))

b <- factor(rep(rep(c(1:3), each = 9), times = 3))

c <- factor(rep(rep(c(1:3), each = 3), times = 9))

y <- c(74.59,75.63,76.7,63.48,63.17,65.99,64,66.35,64.5,

   46.57,44.16,47.96,35.09,36.14,35.16,36.4,34.72,34.58,

   41.82,47.35,45.74,33.33,36.8,33.38,34.13,34.39,34.48,

   89.73,85.24,90.86,82.5,79.44,81.65,77.74,77.02,81.62,

   59.32,62.29,60.7,55.42,55.5,51.17,50.54,53.54,51.85,

   64.5,63.6,65.19,55.07,50.26,53.73,54.57,47.8,48.8,91.56,

   94.49,92.17,82.14,83.16,81.31,83.58,78.63,77.08,60.53,

   60.79,58.57,51.28,52.9,51.54,49.15,48.97,51.61,59.44,

   60.07,60.07,51.94,52.2,50.2,49.45,50.75,49.56)

anovamodel <- aov(y ~ c + Error(a*b))

summary(anovamodel)

lmemodel <- lme(y ~ c, random = ~ 1|a*b)

anova(lmemodel)

 

N.B. You have to load the package 'nlme' before lme() will run at all.
When it does run, it gives the error

 

Error in getGroups.data.frame(dataMix, groups) : 

        Invalid formula for groups

 

I think there is something I haven't understood about the syntax of the
argument 'random' in lme() .   Can anyone explain it to me?

 

Nick Galwey


	[[alternative HTML version deleted]]


