default_initial_variance: Default initial value for variance components

Description Usage Arguments Details Examples

View source: R/options.R

Description

A function of the response vector or matrix (multi-trait case) returning a SPD matrix of conforming dimensions.

Usage

1
2
3
4
5
6
7
default_initial_variance(
  x,
  dim = 1,
  cor.trait = NULL,
  cor.effect = 0.1,
  digits = NULL
)

Arguments

x

numeric vector or matrix with the phenotypic observations. Each trait in one column.

dim

integer. dimension of the random effect for each trait. Default is 1.

cor.trait

a number strictly in (-1, 1). The initial value for the correlation across traits. Default is NULL, which makes the function to take the value from the data. See Details.

cor.effect

a number strictly in (0, 1). The initial value for the correlation across the different dimensions of the random effect. Default is 0.1.

digits

numeric. If not NULL (as default), the resulting matrix is rounded up to 2 significant digits.

Details

The default initial covariance matrix across traits is computed as half the empirical covariance kronecker times a Positive-Definite matrix with Compound Symmetry Structure with a constant diagonal with value 1 and constant off-diagonal elements with the positive value given by cor.effect, i.e.

Σ = Var(x)/2 \%*\% ψ(dim).

This implies that the default initial correlations across traits equal the empirical correlations, except if cor.trait is not NULL.

ψ(dim) is intended to model correlated random effects within traits, and only has an effect when dim > 1.

If any column in x is constant (i.e. empirical variance of 0) then the function stops. It is better to remove this trait from the analysis.

Examples

1
2
3
4
   ## Initial covariance matrix for a bidimensional random effect
   ## acting independently over three traits
   x <- cbind(rnorm(100, sd = 1), rnorm(100, sd = 2), rnorm(100, sd = 3))
   breedR:::default_initial_variance(x, dim = 2, cor.effect = 0.5)

famuvie/breedR documentation built on Sept. 6, 2021, 4:50 a.m.