Skip to content

Help with lme4 model specification

5 messages · Emmanuel Charpentier, ONKELINX, Thierry, boeinguy2

#
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
2: In Spar_loc:`:` :
  numerical expression has 720 elements: only the first used

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?
#
Le mercredi 06 mai 2009 ? 15:21 -0700, boeinguy2 a ?crit :
This is suspicious : Spar_loc doesn't appear in your statement...
Ditto...
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)
Enlightened ?

					Emmanuel Charpentier
#
Please note that the case of characters is important in R. Hence "True"
differs from "TRUE". You need to use REML = TRUE instead of REML = True!
The only valid logical values are TRUE, FALSE, T and F. But I recommend
to use only TRUE and FALSE. Because you can overwrite T and F. You could
do something like T <- FALSE, which is ofcourse not a good idea. TRUE
and FALSE can not be overwritten.

HTH,

Thierry


------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
Namens boeinguy2
Verzonden: donderdag 7 mei 2009 0:21
Aan: r-help at r-project.org
Onderwerp: [R] Help with lme4 model specification


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
2: In Spar_loc:`:` :
  numerical expression has 720 elements: only the first used

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?
:confused:
#
Thanks! I made this correction
ONKELINX, Thierry wrote:

  
    
#
Thanks for your response.
Yes Spar_loc should look suspicious.  I posted the real error messages but
hid the variable names in the model.  Spar_loc is the original form of S.
This did not work.  However I did discover something that does:

AAT<- lmer(Y ~ S + A + (1|H %in% S:A), data=AT, REML=TRUE) 

Not sure why this worked.  I read that it is an alternate way of specifying
nesting.

This runs without error.


______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.