[R] minor bug in lmer

Lngmyers lngmyers at ccu.edu.tw
Wed May 9 08:29:20 CEST 2007


While playing around with the "(1|Subj)" syntax in lmer [lme4], I tried 
out "(0|Subj)". It turns out that this is such a naughty thing to do 
that it crashes the GUI in Windows! The parallel structure in lme [nlme] 
has no effect. Try the following code to see for yourself.

# Make data set
  q = 5; n = 5
  Subj = NULL
  X = NULL
  Y = NULL
  for (i in 1:q) {
   for (j in 1:n) {
    Subj = c(Subj,i)
    X = c(X,j)
    Y = c(Y,i/j)
   }
  }
  fake = data.frame(Subj,X,Y)

# nlme
  library(nlme)
  fake.g.1 = groupedData(Y~1|Subj, data = fake)
  fake.g.lme.1.1 = lme(Y ~ X, random=~1|Subj, data= fake.g.1)

  fake.g.0 = groupedData(Y~0|Subj, data = fake)
  fake.g.lme.0.0 = lme(Y ~ X, random=~0|Subj, data= fake.g.0)

  fake.g.lme.1.0 = lme(Y ~ X, random=~1|Subj, data= fake.g.0)
  fake.g.lme.0.1 = lme(Y ~ X, random=~0|Subj, data= fake.g.1)

  # The following are all identical
  summary(fake.g.lme.1.1)
  summary(fake.g.lme.0.0)
  summary(fake.g.lme.1.0)
  summary(fake.g.lme.0.1)

# lme4
  library(lme4)

  # Same analysis as above:
  fake.lme.1 = lmer(Y ~ X + (1|Subj),data=fake)

  # The following line crashes the WinR GUI!
  fake.lme.0 = lmer(Y ~ X + (0|Subj),data=fake)


-- 
James Myers
Graduate Institute of Linguistics
National Chung Cheng University
Web:    http://www.ccunix.ccu.edu.tw/~lngmyers/



More information about the R-help mailing list