Extract variance components
var_comp.RdThis function provides the variance matrix quantities needed to evaluate heritability with respect to a target random-effect term in a fitted linear mixed model.
Usage
var_comp(
model,
target,
calc_C22 = TRUE,
calc_V = TRUE,
calc_C11 = TRUE,
marginal = TRUE,
stratification = NULL,
solver = c("direct", "LMM"),
...
)Arguments
- model
Model object of class
lmerMod/merModorasreml- target
The name of the random effect for which heritability is to be calculated.
- calc_C22
Logical; whether to compute the prediction error variance (PEV) matrix for the transformed target effect.
- calc_V
Logical; whether to retain the marginal variance matrix of the response and supporting quantities (
V,G,Z,X,idx, andm) in the output.- calc_C11
Logical; whether to compute the variance matrix of the fixed-effect counterpart estimator for the transformed target effect.
- marginal
Logical; if
TRUE, construct marginal (strata-averaged) mappings so that each genotype receives a single averaged effect per term. IfFALSE, mappings will only consider the main genotype effect and ignore the iteracting terms.- stratification
A one-row data frame defining the stratum in which genotype effects should be evaluated. The columns must correspond to model terms that interact with
target.- solver
A string specifying the solver for the PEV matrix. Can be either
"direct"(directly invertV) or"LMM"(Solve the LMM equation).- ...
Additional arguments passed to downstream helper functions.
Value
A named list with the following elements:
n_gNumber of transformed genetic coefficients after applying the mapping matrix
m.gnamesNames of the transformed genetic coefficients.
G_gVariance matrix of the transformed target genetic effect.
C22_gPrediction error variance matrix of the transformed target effect, if
calc_C22 = TRUE; otherwiseNULL.G_g_tildeVariance matrix of the fixed-effect counterpart estimator for the transformed target effect, if
calc_C11 = TRUE; otherwiseNULL.G_g_tilde_no_covVariance matrix of the fixed-effect counterpart estimator for the transformed target effect, without considering target covariance, if
calc_C11 = TRUE; otherwiseNULL.C11_gEstimation error variance matrix of the fixed-effect counterpart estimator for the transformed target effect, if
calc_C11 = TRUE; otherwiseNULL.VMarginal covariance matrix of the response, if
calc_V = TRUE; otherwiseNULL.GVariance matrix of all random effects, if
calc_V = TRUE; otherwiseNULL.ZRandom-effect design matrix, if
calc_V = TRUE; otherwiseNULL.XFixed-effect design matrix, if
calc_V = TRUE; otherwiseNULL.idxIndices of the random-effect coefficients associated with the target term, if
calc_V = TRUE; otherwiseNULL.WLinear mapping from the original target coefficients to the transformed target effect, if
calc_V = TRUE; otherwiseNULL.marginalLogical scalar indicating whether the returned quantities correspond to a marginal definition of the target effect.
stratificationThe user-supplied stratification object, if any.