[R] Once again: aov vs. lme/lmer

Rafael Laboissiere rafael at laboissiere.net
Fri Oct 6 22:46:33 CEST 2006


First of all, I apologize for asking a question that has appeared
recurrently in this mailing list.  However, I have googled for it, have
looked at the mailing list archives, and also looked at Pinheiro & Bates book
(although not very thoroughly, I must confess), to no avail.

Here is the question: I am trying to obtain with lme or lmer the same exact
numerical results (p-values) that I obtain with aov.  Consider the following
data:

  d <- data.frame (a = factor (rep (c (1, 2), c(10, 10))),
                   b = factor (rep (rep (c (1, 2), c(5, 5)),2)),
                   s = factor (rep (1 : 5, 4)),
                   v = rnorm (20))

Let us say that this comes from a repeated measures experiments where all
five subjects (factor s) were tested in all combinations of the two fixed
factors a and b.

With aov, for a model were s, s:a, s:b and s:a:b are random, and a*b
are fixed terms, I would use:

  aov (v ~ a*b + Error (s / (a*b)), data = d)

Is there a way to get the same results using lme or lmer? How should I write
my "random" argument in lme or the "(...|...)" terms in lmer?  Please notice
that I am not interested in philosophical discussions about whether I am
trying to do wrong things.  I would only like to know whether a given R
function could be used in place of another R function.

Thanks in advance for your help,

-- 
Rafael Laboissiere



More information about the R-help mailing list