cov_trait: The model covariance matrix of the trait

Description Usage Arguments Value Examples

View source: R/cov_trait.R

Description

This function returns the expected covariance matrix of a trait vector simulated via sim_trait. Below let there be n individuals.

Usage

1
cov_trait(kinship, herit, sigma_sq = 1)

Arguments

kinship

The n-by-n kinship matrix Φ of the individuals. This may be the true matrix of the genotype simulation or a good estimate of empirical data obtained via the package popkin.

herit

The heritability h^2 (proportion of trait variance due to genetics).

sigma_sq

Overall variance multiplicative factor σ^2 (default 1). This factor corresponds to the variance of an outbred individual.

Value

The n-by-n trait covariance matrix equal to

σ^2 ( 2 h^2 Φ + (1-h^2) I ),

where I is an n-by-n identity matrix.

Examples

1
2
3
4
5
6
7
8
# create a dummy kinship matrix
kinship <- matrix(
             data = c(0.6,0.1,0, 0.1,0.6,0.1, 0,0.1,0.6),
             nrow = 3,
             byrow = TRUE
             )
# covariance of simulated traits
V <- cov_trait(kinship = kinship, herit = 0.8)

OchoaLab/simtrait documentation built on Oct. 18, 2019, 5:42 a.m.