[R] nested versus crossed random effects

Brad Buchsbaum brad at aris.ss.uci.edu
Fri Jan 25 01:01:30 CET 2002



Hi all,

I'm trying to test a repeated measures model with random effects using the
nlme library. Suppose I have two within subjects factors A, B both with
two levels. Using aov I can do:

aov.1 <- aov(y ~ A*B + Error(S/(A+B))

following Pinheiro and Bates I can acheive the analagous mixed-effects
model with:

lme.1 <- lme(y~A*B, random=pdBlocked(list(pdIdent(~1),pdIdent(~A-1),
pdIdent(~B-1))), data=gdat)

But what if we add an additional level of nesting such that each of
the conditions within A and B are repeated multiple times within a
subject. This would then be a trial factor, call it "T". So we'd have
something like this:

s1:t1:a1:b1, s1:t1:a2:b2, s1:t1:a1:b2, s1:t1:a2:b1, s1:t2:a1:b1,
s1:t2:a2:b2 ... s1:t10:a2:b2

s2:t1:a1:b1 .. and so on.

Here the levels of T are held constant for each full iteration of the
crossed factors A and B. But a trial could just as easily mean a single
iteration of any combination of the factors A and B, e.g.

s1:t1:a1:b1, s1:t2:a2:b2, s1:t3:a1:b2 ...

The question is, which of these is the correct specification of the
"Trial" factor and how would I express it using aov and "Error" or,
better yet, using lme? I guess I'm confused as to the practical difference
between coding "Trial" as replicates of certain factorial combinations
or coding "Trial" without respect to other variables in the design.


Forgive me if this is a little adrift for the R-Help mailing list.


Brad Buchsbaum



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list