Problem 1 Analysis of Variance

Estimate the variance component for the sire effect using an analysis of variance. The data is available from https://charlotte-ngs.github.io/gelasmss2021/data/gel_sire_w10.csv. Because the data contains just female animals, the fixed effect of the sex can no longer be estimated.

Hint

  • Use the functions aov() to do the analysis of variance and the function summary() on the ANOVA result to get the relevant parts of the variance components.

Your Solution

Start by reading the data.

# read data using readr::read_csv2()

Compute the anova

# use aov() to get anova result

Compute variance components using the Mean Sq.

# Mean Sq from aov results to get variance components

Problem 2: Variance Components Estimation Using REML

Use the same data set as for Problem 1 and a sire model to estimate the same sire variance \(\sigma_s^2\). The sire model is the linear mixed effects model that contains sire effects as random component. The model can be specified as

\[y = Xb + Zs + e\]

where \(y\) is the vector of observations, \(b\) is the vector of fixed effects which are the same as in Problem 1, \(s\) is the vector of random sire effects and \(e\) is the vector of random error terms.

Hint

  • Use the package pedigreemm to get a REML estimate for the sire variance component \(\sigma_s^2\).
  • We assume that the sires are not related. Hence variance-covariance matrix \(var(s)\) of the sire components are \(var(s) = I * \sigma_s^2\).

Your Solution

The package pedigreemm is used to get to the variance components.

# The function pedigreemm::pedigree() is used to specify the pedigree.

Variance components are part of the results from function pedigreemm() of package pedigreemm.

# Variance components from `pedigreemm::pedigreemm()`

Problem 3: Variance Components Estimation Using an Animal Model

We are given the dataset with the response variable carcass weight (CW) and the predictor variables that resulted from the model selection process from Exercise 1. These consisted of

The data is available from https://charlotte-ngs.github.io/gelasmss2021/data/gel_bp_w10.csv.

We use a mixed linear effects model to estimate the variance components for the random effects in the model.

\[\begin{equation} y = Xb + Za + e \end{equation}\]

where \(y\) is a vector of observations, \(b\) is a vector of fixed effects found to be relevant in Exercise 1, \(a\) is a vector of random breeding values and \(e\) is a vector of random errors.

Hint

  • Use the package pedigreemm to get an estimate of the variance components

Your Task

  • Estimate the variance components \(\sigma_a^2\) and \(\sigma_e^2\) for the two random component \(a\) and \(e\), respectively.

Your Solution

Start by reading the data.

# Read data using `readr::read_csv2()`

Use pedigreemm::pedigree() to specify the pedigree.

# pedigree ...

Variance components are obtained from function pedigreemm()

# Variance components ...

Latest Changes: 2021-05-02 09:28:38 (peter)

LS0tCnRpdGxlOiBHZW5ldGljIEV2YWx1YXRpb24gLSBOb3RlYm9vayAzCmF1dGhvcjogUGV0ZXIgdm9uIFJvaHIKZGF0ZTogMjAyMS0wNC0zMApvdXRwdXQ6IGh0bWxfbm90ZWJvb2sKLS0tCgoKYGBge3Igc2V0dXAsIGluY2x1ZGU9RkFMU0V9CmtuaXRyOjpvcHRzX2NodW5rJHNldChlY2hvID0gVFJVRSkKYGBgCgoKIyMgUHJvYmxlbSAxIEFuYWx5c2lzIG9mIFZhcmlhbmNlCkVzdGltYXRlIHRoZSB2YXJpYW5jZSBjb21wb25lbnQgZm9yIHRoZSBzaXJlIGVmZmVjdCB1c2luZyBhbiBhbmFseXNpcyBvZiB2YXJpYW5jZS4gVGhlIGRhdGEgaXMgYXZhaWxhYmxlIGZyb20gYGh0dHBzOi8vY2hhcmxvdHRlLW5ncy5naXRodWIuaW8vZ2VsYXNtc3MyMDIxL2RhdGEvZ2VsX3NpcmVfdzEwLmNzdmAuIEJlY2F1c2UgdGhlIGRhdGEgY29udGFpbnMganVzdCBmZW1hbGUgYW5pbWFscywgdGhlIGZpeGVkIGVmZmVjdCBvZiB0aGUgc2V4IGNhbiBubyBsb25nZXIgYmUgZXN0aW1hdGVkLiAKCgojIyMgSGludAoqIFVzZSB0aGUgZnVuY3Rpb25zIGBhb3YoKWAgdG8gZG8gdGhlIGFuYWx5c2lzIG9mIHZhcmlhbmNlIGFuZCB0aGUgZnVuY3Rpb24gYHN1bW1hcnkoKWAgb24gdGhlIEFOT1ZBIHJlc3VsdCB0byBnZXQgdGhlIHJlbGV2YW50IHBhcnRzIG9mIHRoZSB2YXJpYW5jZSBjb21wb25lbnRzLgoKCiMjIyBZb3VyIFNvbHV0aW9uClN0YXJ0IGJ5IHJlYWRpbmcgdGhlIGRhdGEuIAoKYGBge3J9CiMgcmVhZCBkYXRhIHVzaW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