[R] lme4 problem: model defining and effect estimation ------ question from new bird to R community from SAS community
peter dalgaard
pdalgd at gmail.com
Sat Apr 16 09:45:35 CEST 2011
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
More information about the R-help
mailing list