An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110415/ca98ccba/attachment.pl>
lme4 problem: model defining and effect estimation ------ question from new bird to R community from SAS community
6 messages · Nilaya Sharma, Peter Dalgaard, Dieter Menne
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110415/271ae959/attachment.pl>
On Apr 16, 2011, at 04:21 , Nilaya Sharma wrote:
genetic_evaluation <- read.table(textConnection("
sire dam adg
1 1 2.24
1 1 1.85
1 2 2.05
1 2 2.41
....
4 2 1.86 4 2 1.79 5 1 2.82 5 1 2.64 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)
You're missing the equivalent of the SAS class statement. Grouping variables need to be factors: genetic_evaluation<-transform(genetic_evaluation, sire=factor(sire), dam=factor(dam)) Also, you probably don't want a random main effect of dam, so lmer(adg ~ 1 + (1|sire) + (1|dam:sire), data=genetic_evaluation) or even lmer(adg ~ 1 + (1|sire/dam), data=genetic_evaluation)
Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
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.
On Apr 16, 2011, at 09:52 , Dieter Menne wrote:
Thanks for providing a self-contained example. The error message is really a bit confusing (anybody around who understands what lme thinks here?),
It's not thinking at all, it's just evaluating a:b (so usual model formula interpretation is partially disabled? Hm, well, multiplying the two continuous variables wouldn't make sense either, I suppose.) and what you see is a variant of
(1:2):(1:2)
[1] 1 Warning messages: 1: In (1:2):(1:2) : numerical expression has 2 elements: only the first used 2: In (1:2):(1:2) : numerical expression has 2 elements: only the first used
Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110416/6389d33e/attachment.pl>