[R-sig-ME] error in lmer: length(f1) == length(f2) is not TRUE

Ben Bolker bbolker at gmail.com
Wed Oct 17 20:02:41 CEST 2012


joana martelo <jmmartelo at ...> writes:

> 
> Thanks for your answers, but it still doesn't work. 
> Trial and fish.id are factors, but I get the same error:
> 
> > Error: length(f1) == length(f2) is not TRUE In addition: Warning 
> > messages:
> > 1: In fish.id:trial :
> >   numerical expression has 2518 elements: only the first used
> > 2: In fish.id:trial :
> >  numerical expression has 2518 elements: only the first used
> 
> I've tried to find the answer in other mailing lists, but they all give the
same answer....
> 
> Any ideas of what the mistake might be?
> 

  Not sure, but I strongly recommend that you put your response
variable along with all of your predictor variables into a data frame
together and use the data= argument to glmer().  It's extremely easy
to have a modified version of one of the predictors floating around
in the workspace.  It's also possible (although I think this would
technically constitute a bug in lmer ...) that this is caused by NAs
somewhere in the dataset, although I couldn't provoke it with this
sample:

d <- data.frame(y=rnorm(200),f1=sample(LETTERS[1:5],200,replace=TRUE),
    f2=sample(letters[1:5],200,replace=TRUE))
d$f2[100] <- NA
lmer(y~1+(1|f1/f2),data=d)

  If putting your variables into a data frame and using na.omit()
on it don't make the problem go away, then we'll need a reproducible
example to get any farther ...



More information about the R-sig-mixed-models mailing list