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

This function computes the total phenotypic variance-covariance matrix on the observed or expected scales.

1 2 |

`mu` |
Vector of latent intercepts estimated from a GLMM (ignored if predict is not |

`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) |

`var.func` |
Function giving the variance function for each trait. This function should accept a vector and yield a vector of the same length, see Details and Example below. (function) |

`mvmean.obs` |
Optional parameter giving the multivariate phenotypic mean on the observed scale. Automatically computed if not provided. (numeric) |

`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) |

`exp.scale` |
Should the variance-covariance matrix be computed on the expected scale? |

`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 |

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 phenotypic variance-covariance matrix on the observed scale (or on the expected scale if `exp.scale`

is `TRUE`

).

To do so, it also requires the inverse functions of the link functions (`link.inv`

) and the distribution variance functions (`var.func`

). For an analysis with d traits, the function given to these arguments should use a vector of length d and yield a vector of length d (see Example below).

This function yields the phenotypic variance-covariance on the observed or expected scale. (numeric)

Pierre de Villemereuil & Michael B. Morrissey

`QGvar.exp`

, `QGvar.dist`

, `QGmvparams`

, `QGlink.funcs`

, `QGmvpsi`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ```
##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
inv.links=function(vec){c(pnorm(vec[1]),vec[2])} #probit link, identity link respectively
#Setting up the distribution variance functions
var.funcs=function(vec){c(pnorm(vec[1])*(1-pnorm(vec[1])),0)} #probit and identity link respectively
#The first element of the vector is p*(1-p) (variance of a binomial)
#The second element is 0 because the identity link does not create variance
#Computing the multivariate mean on observed scale
#Phenotypic VCV matrix on observed scale
QGvcov(mu=mu, vcov=P, link.inv=inv.links, var.func=var.funcs)
#Phenotypic VCV matrix on the expected scale
QGvcov(mu=mu, vcov=P, link.inv=inv.links, var.func=var.funcs,exp.scale=TRUE)
QGvar.exp(mu=0,var=1,link.inv=pnorm) #Same variance on the expected scale
QGvar.exp(mu=0,var=1,link.inv=pnorm)+
QGvar.dist(mu=0,var=1,var.func=function(x){pnorm(x)*(1-pnorm(x))})
#Same variance on the observed scale
#Reminder: the results are the same here because we have no correlation between the two traits
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.