With repeated observations bayz can't automatically merge repeated phenotype data with data like genotypes, because there will be repeated IDs in the phenotype file. One option is to merge this kind of data yourself, but it requires to copy data like genotypes several times in the phenotype file. This creates unnecessarily big files and also increases computing time. Read further below how bayz can handle this situation efficiently using hierarchical models. The hierarchical model, in a way, merges the phenotype and genotype data "in the model", instead of literally combining/merging the data.
The key elements of this approach are to make a two-level model where:
data (1) file=weights.txt mouseID age weight data mouseID (2) file=genotypes.txt mouseID genot !genot012 data genot map file=snp_names.txt genot model weight = mean fac.mouseID (3) fac.mouseID.weight = add.genot (4) resid.weight ~ ...... (5) resid.fac.mouseID.weight ~ ...... (6) ........Notes:
The hierarchical model will have residuals on two levels: the regular residual on the phenotype level, and a second residual on the ID level (animal ID or plant genotype/line/variety). When the second model level includes genetic or whole-genome genomic effects, the residual ID effect models covariance between repeated observations not explained by genetic/genomic effects. In animals, with repeated measures on the same individual, this is typically interpreted as permanent environmental (PE) effects, although in principle also including non-additive genetic effects that cannot be distinguished from PE effects. In plants, the situation often is that the repeated phenotypes are measured on the same genotype but not literally on the same plants, which means there is no environmental correlation. This allows to interpret the residual ID variance as non-additive genetic variance that can be included in a broad sense heritability.
The parameter names in hierarchical models will become quite long, because the left hand side like "fac.mouseID.weight" is used as the trait name and appended to all effects modelled on the second level. The parameters can be re-named to condense all names, as in the following example changing the name for "fac.mouseID.weight" to "anim":
model weight = mean fac.mouseID !name=anim anim = fac.sex fac.diet resid.weight ~ ...... resid.anim ~ ...... ........