[R] Help with lme4 model specification

Emmanuel Charpentier charpent at bacbuc.dyndns.org
Thu May 7 07:55:58 CEST 2009


Le mercredi 06 mai 2009 à 15:21 -0700, boeinguy2 a écrit :
> I am new to R and am trying to specify a model for mixed model analysis. 
> When I run the following model I get an error:
> 
> AAT<- lmer(Y ~ S + A + (1|S:A/H), data=AT, REML=True)
> 
> The error looks like this:
> 
> Error in Spar_loc:`:` : NA/NaN argument
> In addition: Warning messages:
> 1: In model.matrix.default(mt, mf, contrasts) :
>   variable 'Spar_loc' converted to a factor

This is suspicious : Spar_loc doesn't appear in your statement...

> 2: In Spar_loc:`:` :
>   numerical expression has 720 elements: only the first used

Ditto...

> I am having trouble specifying th random component.  It should reflect the
> random term as H nested within the interaction of S & A.  What am I doing
> wrong?

The precedence of modelling operators is not very clear (and does not
seem to be formally defined in the "standard" documentation...). In
doubt, use parentheses.

So try ...+(1|(S:A)/H), just in case...

You might also try to define it outside the model by adding variables :

AT<-within(AT,{SA=S:A, SAH=SA:H[,drop=TRUE]})
AAT<-lmer(y~S+A+(1|SAH),data=AT,REML=TRUE)

> :confused:

Enlightened ?

					Emmanuel Charpentier




More information about the R-help mailing list