[R-sig-ME] fitting an animal model

Douglas Bates bates at stat.wisc.edu
Fri Jun 20 16:41:34 CEST 2008

On Fri, Jun 20, 2008 at 4:59 AM, Anna Santure <asanture at gmail.com> wrote:
> Hi everyone,

> I have come across some very helpful conversations on the archives for this
> list regarding fitting animal models, but I'm afraid I'm still a bit lost!
> Jon Hallander gave a good description of the model in "[R-sig-ME]
> incorporate pedigree into lmer" discussion Feb 6, 2007, pasted below:
> Animal model:

> "I am using a mixed linear model including both random and fixed effects:
> y = Xb + Za + e
> where the vector y are observed individual data, b is a vector of fixed
> effects, a is an individual additive random effect that are normally
> distributed vectors with (co)variance A*var(a). X and Z are incidence
> matrices relating the fixed and random effects (b and a) with the
> observations y. Furthermore, e is the error term, normally distributed with
> mean zero and variance var(e). A is the additive genetic relationship matrix
> which is computed using the pedigree information (given below). A typical
> data might look like this:
> Id Sire Dam y (i.e. weight in kg)
> 1  Na   Na  4.3
> 2  Na   Na  4.7
> 3  1    2   4.4
> 4  1    Na  4.1
> 5  4    2   4.3
> 6  4    2   4.2" (end of pasted passage).

> I would like to estimate the additive variance and error variance (in order
> to estimate heritability) and it would also be nice to predict the
> "breeding" (additive) values for each individual.

> My (simulated) data set "animalmodel.txt" contains information on the animal
> id, the generation and the trait value (simulated just as additive effects
> plus an error), with 10 offspring from 13 parents all with trait data, along
> with a 23x23 relationship matrix linking animals to their parents and sibs
> ("covmatrix.txt"). There is a constraint at this point as I have a covmatrix
> rather than a pedigree so some of the previously suggested methods using
> "pedigree" / "kinship" might not work.
> Based on previous discussions in this list I tried fitting the following:
> 1. animaldata<-read.delim("data_animal.txt")
> 2. covmatrix<-read.table("covmatrix.txt")
> 3. correlation=corSymm(covmatrix[lower.tri(covmatrix)], fixed=TRUE)
> 4. correlation1<-Initialize(correlation,data=animaldata)
> 5.
> animalmodel<-lme(trait~generation,random=~1|animal,correlation=correlation1,data=animaldata)
> I have a number of problems at this point. First, I am not confident that
> the model is right (actually, I imagine I probably should be somehow
> including the random effects in the model statement?). Second, I am not sure
> the function is correct (perhaps I shouldn't be using lme in the nlme
> package? would lmer in lme4 and then VarCorr be better?). Third, I am unsure
> how to find the additive variance in the output, and particularly how to
> predict breeding values and heritability from here.
> I would very much appreciate any guidance!
> With many thanks and best wishes,

Did you intend that the files you mention (data_animal.txt,
covmatrix.txt) would be included with your message?  I didn't see any

Ana Vazquez and I are writing a package called pedigreemm
(http://r-forge.r-project.org/projects/pedigreemm/) for incorporating
the information from a pedigree into mixed models based on lme4.  It's
not yet ready for release but we may be able to work with your example
to show you how an animal model can be fit, and in the process refine
our package and obtain an example.  Perhaps you could provide us with
the data - on-list or off-list, whichever you prefer.

> Anna Santure
>        [[alternative HTML version deleted]]
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

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