[R] lme4 problem: model defining and effect estimation ------ question from new bird to R community from SAS community

Dieter Menne dieter.menne at menne-biomed.de
Sat Apr 16 09:52:54 CEST 2011


Nilaya Sharma wrote:
> 
> I was trying to fit a mixed model in animal experiment but stuck at simple
> point. The following similar example is from SAS mixed model pp 212.
> 
> 
> genetic_evaluation <- read.table(textConnection("
> sire dam adg
> 1  1  2.24
> 1  1  1.85
> ...
> 5  2  2.58
> 5  2  2.56"), header = TRUE)
> 
> # my R practice codes
> require (lme4)
>  lmer(adg ~ 1 + (1|sire) + (1|dam/sire), data=genetic_evaluation)
> 
>  ****error message********************************************88
>  Error: length(f1) == length(f2) is not TRUE
> In addition: Warning messages:
> 

Thanks for providing a self-contained example. The error message is really a
bit confusing (anybody around who understands what lme thinks here?), but
the solution is simple. Just make sure that dam and sire are factors:

genetic_evaluation$dam = as.factor(genetic_evaluation$dam)
genetic_evaluation$sire = as.factor(genetic_evaluation$sire)

I recommend the excellent course notes in the MCMCglmm package as a
complementary reading.

Dieter




--
View this message in context: http://r.789695.n4.nabble.com/lme4-problem-model-defining-and-effect-estimation-question-from-new-bird-to-R-community-from-SAS-comy-tp3453530p3453690.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list