[R-sig-ME] pedigreemm number of levels per grouping factor

Ben Bolker bbolker at gmail.com
Wed Feb 5 19:35:21 CET 2014


On 14-02-04 06:34 PM, Wilson, Alastair wrote:
> I’m trying to fit a pedigree-based mixed model (ie animal model) to
> estimate a genetic variance and a couple of fixed effects in a
> simulated data set. I’ve fitted the model using AsReml-R and
> MCMCglmm. I wanted to try using pedigreemm but get a error
> 
> Error in checkNlevels(reTrms$flist, n = n, control) : number of
> levels of each grouping factor must be < number of observations
> 
> I *think* this is telling me I don’t have multiple observations per
> factor level (here ID) which is true. However, I shouldn’t need
> repeat measures to estimate the random effect variance here (i.e.
> VA), so am assuming I have not got the code (below) right. Any
> pointers v gratefully received.
> 
> Alastair

  I'm not sure, but I guess that this is one of the cases where
individual-level random effects *do* make sense in a LMM context.  I
don't know whether pedigreemm allows you to pass arguments through to
lmer, but if it does you can use
control=lmerControl(check.nobs.vs.nlev="ignore") to suppress this check.
 You might also be able to do this globally via

options(lmerControl=list(check.nobs.vs.nlev="ignore"))

  (The maintainer of the package might want to consider suppressing this
check by default, if this is a common issue ...)

  Ben Bolker



> 
> ############### library(pedigreemm) setwd("c:/prussia/")
> 
> voles<-read.table("voles.txt", header=T) 
> voles$ID<-as.factor(voles$ID) voles$sex<-as.factor(voles$sex)
> 
> volesPED<-read.table("volesPED.txt",header=T) 
> volesPED2<-pedigree(volesPED$SIRE,volesPED$DAM,volesPED$ID)
> 
> model3<-pedigreemm(size~forage+sex+(1|ID),
> pedigree=list(ID=volesPED2), data=voles, REML=TRUE)
> 

  It would be nice if the example were reproducible ...



More information about the R-sig-mixed-models mailing list