[R] beginner's questions about lme, fixed and random effects

Jonathan Baron baron at cattell.psych.upenn.edu
Mon Dec 3 12:08:06 CET 2001


I'm trying to understand better the differences between fixed and
random effects by running very simple examples in the nlme
package.  My first attempt was to try doing a t-test in lme.
This is very similar to the Rail example that comes with nlme,
but it has two groups instead of five.

So I try

a1 <- 1:10
a2 <- 7:16
t.test(a2,a1)

getting t(18)=4.43, p=.0003224.  Then I try to do it with lme:

a12 <- c(a1,a2)
grp <- factor(rep(1:2,c(10,10)))

Now, at this point, I think I should be able to do something like
this:
lme(a12~grp)
or
lme(a12~1|grp)
but I keep getting an error message, "Invalid formula for
groups."  So I tried making a groupedData object:

data1 <- as.data.frame(cbind(a12,grp))
gd1 <- groupedData(a12~1|grp,data=as.data.frame(cbind(a12,grp)))

Now I can do
lme(gd1)
or
lme(gd1,random=1|grp)
or many other things, but nothing seems to yield anything like
the t test, and I'm not even sure what the fixed effect test
(with a p of .011 with summary(lme(gd1))) is testing.  (It
doesn't seem to be about whether the grand mean of a12 is greater
than zero.)  I've been studying the relevant documentaion,
including Pinheiro and Bates's book, but I'm still stumped.  I'm
sure I'm being very dense about something very simple, like,
"This doesn't make any sense."  But why not?

All this is leading up to a real application to a much more
complicated problem, but I think I need to understand the simple
stuff first.

Jon Baron
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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