QGmvmean: Compute the multivariate phenotypic mean on the observed...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/source.mv.R

Description

This function calculates the multivariate phenotypic mean on the observed scale from multivariate latent mean and variance-covariance matrix.

Usage

1
2
QGmvmean(mu = NULL, vcov, link.inv, predict = NULL,
         rel.acc = 0.001, width = 10, mask = NULL) 

Arguments

mu

Vector of latent intercepts estimated from a GLMM (ignored if predict is not NULL). (numeric)

vcov

Latent total phenotypic variance-covariance matrix estimated from a GLMM. Usually, the sum of all the estimated variance-covariance matrices. (numeric)

link.inv

Inverse functions of the link functions. This function should accept a vector and yield a vector of the same length, see Details and Example below. (function)

predict

Optional matrix of predicted values on the latent scale (each trait in each column). The latent predicted values must be computed while only accounting for the fixed effects (marginal to the random effects). (numeric)

rel.acc

Relative accuracy of the integral approximation. (numeric)

width

Parameter for the integral computation. The default value is 10, which should be sensible for most models. (numeric)

mask

Masking filter for removing predictions that don't exist in the population (e.g. female predictions for males for a sex - based bivariate model). Should the same dimensions as predict and values should be FALSE when the predictions should be filtered out.

Details

This function needs the multivariate latent population mean (mu) or the marginal predicted values (predict) and the total latent variance-covariance matrix (vcov) to compute the observed phenotypic mean.

To do so, it also requires the inverse functions of the link functions (link.inv). For an analysis with d traits, the function given to the link.inv argument should use a vector of length d and yield a vector of length d (see Example below).

Value

This function yields the mutlivariate phenotypic mean on the observed scale. (numeric)

Author(s)

Pierre de Villemereuil & Michael B. Morrissey

See Also

QGmean, QGmvparams, QGlink.funcs, QGvcov, QGmvpsi

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Example using a bivariate model (Binary trait/Gaussian trait)
# Parameters
mu <- c(0, 1)
P <- diag(c(1, 4))

# Note: no phenotypic, nor genetic correlations, hence should be equal to univariate case!

# Setting up the link functions
# Note that since the use of "cubature" to compute the integrals,
# the functions must use a matrix as input and yield a matrix as output,
# each row corresponding to a trait
inv.links <- function(mat) {matrix(c(pnorm(mat[1, ]), mat[2, ]), nrow = 2, byrow = TRUE)}
# probit link and identity link respectively

# Computing the multivariate mean on observed scale
QGmvmean(mu = mu, vcov = P, link.inv = inv.links)
QGmean(mu = 0, var = 1, link.inv = pnorm)     # Same result than trait 1!
QGmean(mu = 1, var = 4, link.inv = function(x){x})     # Same result than trait 2!
# Reminder: the results are the same here because we have no correlation between the two traits

QGglmm documentation built on Jan. 7, 2020, 5:06 p.m.