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

Joehanes, Roby (NIH/NHLBI) [F] roby.joehanes at nih.gov
Tue Oct 16 20:57:38 CEST 2012


Hi Joana,

Most likely, the problem is: length(trial) != length(reactive.dist).

Hope this helps,
Roby

On 10/16/12 2:28 PM, "joana martelo" <jmmartelo at fc.ul.pt> wrote:
> Dear list
> 
>  
> 
> I'm trying to model fish data with a gaussian distribution for prey reactive
> distance obtained in lab experiments. Each experimental trial consisted of
> giving 1 prey to fish every x min., for a total of 20 prey, and measuring
> the reactive distance of fish to the prey. My explanatory variables are
> current velocity (0, 8, 12, 26 cm/s), fish size (small, medium and large),
> density (2, 4 and 6 fish), trial and fish.id, and I did 3 replicates of each
> trial, using each fish only once. Because not all fish reacted to the prey,
> the number of reactive distances is not the same for each fish, and hence
> not the same for each trial. I wonder whether with this experimental design
> I can consider fish.ID and trial as random effects and treat the other
> variables as fixed effects.
> 
>  
> 
> I¹m using lme4 and tried:
> 
>  
> 
> model<-lmer(reactive.dist~velocity+density+(1|trial/fish.id),family=gaussian
> )
> 
>  
> 
> but got this error and warning:
> 
>  
> 
> 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
> 
>  
> 
> Is this because I don¹t have the same number of reactive distances per fish?
> 
> 
>  
> 
> When I do:
> 
> model<-lmer(reactive.dist~velocity+density(1|fish.id),family=gaussian)
> 
> it works fineŠŠ.
> 
> Any suggestions would be greatly appreciated!
> 
> The best
> 
> Joana
> 
>  
> 
> Joana Martelo, PhD Student
> 
> Centro de Biologia Ambiental
> 
> Departamento de Biologia Animal
> 
> Faculdade de Ciências, Edificio C2,5ºPiso,Sala 2.5.15B
> 
> 1749-016 Lisboa, Portugal
> 
> http://ffishgul.fc.ul.pt
> 
>  
> 
>  
> 



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