Skip to content

lme4, error in mer_finalize(ans)

2 messages · Ben Meijering, Douglas Bates

#
Using lmer() on my data results in an error. The problem, 
I think, is my model specification. However, lm() works 
ok.
I recreated this error with a more simple dataset. (See 
code below.)

# word and letter recognition data
# two within factors:
# word length: 4, 5, 6 letters
# letter position: 1-4 (in 4-letter words), 1-5 (in 
5-letter words), 1-6 (in 6-letter words)
# one dependent variable:
# reaction time

# make artificial data
length <- c(rep(4,4), rep(5,5), rep(6,6)) # independent 
variable "word length"
length <- factor(c(rep(length, 2)))
pos <- c(1:4, 1:5, 1:6) # independent variable "letter 
position"
pos <- factor(c(rep(pos, 2)))
rt <- c(rnorm(15, 200, sd=10), rnorm(15, 300, sd=15)) # 
dependent variable "reaction time"
df <- data.frame(subj=factor(c(rep(1:2, each=15))), 
length=length, pos=pos, rt=rt)

# to use lmer from lme4 package
library(lme4)

# first fit a linear model with letter position nested in 
word length
lm(rt ~ length + length:pos, data=df)

# fit a mixed effects model, with subj (participant) as 
random effect
lmer(rt ~ length + length:pos + (1 | subj), data=df)

Using lmer() results in an error: Error in 
mer_finalize(ans) : Downdated X'X is not positive 
definite, 13. I don't experience any problems using lm(). 
Does anyone know where things go wrong?

~ Ben Meijering
#
On Fri, Dec 5, 2008 at 3:44 PM, B. Meijering <B.Meijering at student.rug.nl> wrote:
That, admittedly obscure, error message relates to the fixed-effects
specification rt ~ length + length:pos being rank deficient.  If you
look at the summary of the linear model fit you will see that there
are 3 coefficients that are not determined because of singularities.
The lm function detects the singularities and fits a lower-rank model.
 The lmer function is not as sophisticated.  It just detects the
singularities and quits.

The length and the position are confounded.
pos
len 1 2 3 4 5 6
  4 2 2 2 2 0 0
  5 2 2 2 2 2 0
  6 2 2 2 2 2 2

(By the way, I changed the name of the length variable to len as
typing "length" makes me expect the function called length.)

Even when you remove this confounding by creating the len:pos
interaction separately as a factor, you will still get singularities
because there is only one len:pos combination for len = 6.

You will need to think of a way of parameterizing the fixed effects
without the singularities.  You can check for singularities in the
summary of the lm fit.