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

From: peter dalgaard <pdalgd_at_gmail.com>
Date: Sat, 16 Apr 2011 09:45:35 +0200

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

______________________________________________
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.
Received on Sat 16 Apr 2011 - 07:47:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 16 Apr 2011 - 16:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive