[R-sig-ME] pedigreemm with one observation per individual
Aaron Rendahl
arendahl at stat.umn.edu
Wed Feb 10 17:47:20 CET 2010
I'm trying to fit a mixed model using pedigreemm, but unlike any of
the examples, I only have one observation per individual.
I'm getting the following error:
Error in function (fr, FL, start, REML, verbose) :
Number of levels of a grouping factor for the random effects must
be less than the number of observations
which makes sense when the random effects are uncorrelated; as Spencer
Graves wrote when reporting this issue, "there are zero degrees of
freedom to distinguish 'group' from Residual."
However, with correlated random effects with a known correlation
pattern, as with pedigree data, it seems this is a reasonable thing to
do. Is there a way to tell lme4 to allow this in this case? Or is
this still not a reasonable thing to do? Thanks for any comments or
suggestions you may have.
I'm running R 2.10.1, pedigreemm 0.2-4, and lme4 0.999375-32.
I've recreated the error using data from the milk dataset from
pedigreemm, as below.
> library(pedigreemm)
>
> # to simplify, just get one herd and remove unneeded columns
> milk <- within(milk, sdMilk <- milk / sd(milk))
> m<-subset(milk, herd==89)
> m<-m[,c("id","lact","dim","sdMilk")]
>
> # the data now has three measurements per cow
> head(m)
id lact dim sdMilk
1 6489 1 286 4.118756
2 6489 2 305 4.828023
3 6489 3 203 3.540520
4 6490 1 281 4.624768
5 6490 2 277 4.483228
6 6490 3 289 4.894880
>
> # and fitting a model works fine
> fm <- pedigreemm(sdMilk ~ lact + log(dim) + (1|id),
+ data = m, pedigree = list(id = pedCowsR))
>
> # but if I use only one measurement for each cow, as follows
> m1<-subset(m, lact==1)
> head(m1)
id lact dim sdMilk
1 6489 1 286 4.118756
4 6490 1 281 4.624768
7 6491 1 305 5.287302
8 6492 1 281 4.421290
12 6493 1 305 4.374557
16 6494 1 305 3.783129
>
> # it then fails
> fm1 <- pedigreemm(sdMilk ~ log(dim) + (1|id),
+ data = m1, pedigree = list(id = pedCowsR))
Error in function (fr, FL, start, REML, verbose) :
Number of levels of a grouping factor for the random effects
must be less than the number of observations
--
Aaron Rendahl, Ph.D.
Statistical Consulting Manager
School of Statistics, University of Minnesota
NEW OFFICE (as of June 2009):
48C McNeal Hall, St. Paul Campus
612-625-1062
www.stat.umn.edu/consulting
More information about the R-sig-mixed-models
mailing list