sim_trait_mvn {simtrait} | R Documentation |
Simulate traits from a kinship matrix under the infinitesimal model
Description
Simulate matrix of trait replicates given a kinship matrix and model parameters (the desired heritability, group effects, total variance scale, and mean).
Although these traits have the covariance structure of genetic traits, and have heritabilities that can be estimated, they do not have causal loci (an association test against any locus should fail).
Below n
is the number of individuals.
Usage
sim_trait_mvn(
rep,
kinship,
herit,
mu = 0,
sigma_sq = 1,
labs = NULL,
labs_sigma_sq = NULL,
tol = 1e-06
)
Arguments
rep |
The number of replicate traits to simulate. Simulating all you need at once is more efficient than simulating each separately (the kinship matrix is eigendecomposed once per run, shared across replicates). |
kinship |
The |
herit |
The desired heritability (proportion of trait variance due to genetics). |
mu |
The desired parametric mean value of the trait (scalar, default 0). |
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 |
tol |
Tolerance factor for an internal test of positive semi-definiteness of the trait covariance matrix.
Procedure fails if any eigenvalues are smaller than |
Value
A rep
-by-n
matrix containing the simulated traits along the rows, individuals along the columns.
See Also
Examples
# create a dummy kinship matrix
# make sure it is positive definite!
kinship <- matrix(
data = c(
0.6, 0.1, 0.0,
0.1, 0.5, 0.0,
0.0, 0.0, 0.5
),
nrow = 3
)
# draw simulated traits (matrix)
traits <- sim_trait_mvn( rep = 10, kinship = kinship, herit = 0.8 )
traits