[R] lmer for 3-way random anova

Dick Beyer dbeyer at u.washington.edu
Fri Dec 9 20:25:09 CET 2005


I have been using lme from nlme to do a 3-way anova with all the effects treated as random.  I was wondering if someone could direct me to an example of how to do this using lmer from lme4.

I have 3 main effects, tim, trt, ctr,  and all the interaction effects tim*trt*ctr. The response variable is ge.

Here is my lme code:


   dat <- data.frame(ge=ge,trt=factor(trt),tim=factor(tim),ctr=factor(ctr))
   dat$grp = as.factor(rep(1, nrow(dat)))

# dim(dat) = 216x5

   w <- lme(ge ~ 1,data=dat,
   random = list(
   grp = pdBlocked(list(  pdIdent(~ trt - 1)
                         ,pdIdent(~ tim - 1)
                         ,pdIdent(~ ctr - 1)
                         ,pdIdent(~ trt:tim - 1)
                         ,pdIdent(~ trt:ctr - 1)
                         ,pdIdent(~ tim:ctr - 1)
                         ,pdIdent(~ trt:tim:ctr - 1)
                        )
                  )
                )
              )

I was trying the following as a starting place:

   lmer(ge~1+(1|tim)+(1|trt)+(1|ctr), data=dat)

but this causes my R session to terminate.

> sessionInfo()
R version 2.2.0, 2005-11-15, i386-pc-mingw32

attached base packages:
[1] "methods"   "stats"     "graphics"  "grDevices" "utils"     "datasets"  "base"

other attached packages:
      lme4   lattice    Matrix
  "0.98-1" "0.12-11"  "0.99-2"

Thanks very much for any help or pointers,
Dick
*******************************************************************************
Richard P. Beyer, Ph.D.	University of Washington
Tel.:(206) 616 7378	Env. & Occ. Health Sci. , Box 354695
Fax: (206) 685 4696	4225 Roosevelt Way NE, # 100
 			Seattle, WA 98105-6099
http://depts.washington.edu/ceeh/ServiceCores/FC5/FC5.html
http://staff.washington.edu/~dbeyer




More information about the R-help mailing list