cov_trait {simtrait} | R Documentation |
The model covariance matrix of the trait
Description
This function returns the expected covariance matrix of trait vectors simulated via sim_trait()
and sim_trait_mvn()
.
Below there are n
individuals.
Usage
cov_trait(kinship, herit, sigma_sq = 1, labs = NULL, labs_sigma_sq = NULL)
Arguments
kinship |
The |
herit |
The desired heritability (proportion of trait variance due to genetics). |
sigma_sq |
The desired parametric variance factor of the trait (scalar, default 1). Corresponds to the variance of an outbred individual. |
labs |
Optional labels assigning individuals to groups, to simulate group effects.
If vector, length must be number of individuals.
If matrix, individuals must be along rows, and levels along columns (for multiple levels of group effects).
The levels are not required to be nested (as the name may falsely imply).
Values can be numeric or strings, simply assigning the same values to individuals in the same group.
If this is non- |
labs_sigma_sq |
Optional vector of group effect variance proportions, one value for each level given in |
Value
The n
-by-n
trait covariance matrix, which under no environment effects equals
sigma_sq * ( herit * 2 * kinship + sigma_sq_residual * I )
,
where I
is the n
-by-n
identity matrix and sigma_sq_residual = 1 - herit
.
If there are labels, covariance will include the specified block diagonal effects and sigma_sq_residual = 1 - herit - sum(labs_sigma_sq)
.
See Also
Examples
# create a dummy kinship matrix
kinship <- matrix(
data = c(
0.6, 0.1, 0.0,
0.1, 0.6, 0.1,
0.0, 0.1, 0.6
),
nrow = 3,
byrow = TRUE
)
# covariance of simulated traits
V <- cov_trait(kinship = kinship, herit = 0.8)