Description Usage Arguments Details Value Author(s) See Also Examples
This function computes the variance emerging from the error distribution around the individual expected value. This variance, added to the variance of the individual expected values themselves (see QGvar.exp
) yields the total observed phenotypic variance.
1 |
mu |
Latent intercept estimated from a GLMM (ignored if predict is not |
var |
Latent total phenotypic variance estimated from a GLMM. Usually, the sum of the estimated variances of the random effects, plus the "residual" variance. (numeric of length 1) |
var.func |
Function giving the variance of the distribution according to a given latent value. (function) |
predict |
Optional vector of predicted values on the latent scale (i.e. matrix product Xb). The latent predicted values must be computed while only accounting for the fixed effects (marginal to the random effects). (numeric) |
width |
Parameter for the integral computation. The integral is evaluated from |
The distribution variance is the part of the observed variance emerging from the error distribution. It is calculated as an average error variance over all possible latent values. The distribution variance added to the variance of the expected values gives the total phenotypic variance on the observed scale.
The variance function (var.func
) is a function giving the variance of the error distribution of the GLMM according to a given latent value.
Using a Poisson distribution with a logarithm link, this function is exp(x)
, because the variance of a Poisson is its mean. Using a Negative Binomial distribution with a logarithm link, this function will now be exp(x) + exp(2 * x) / theta
. Note that the dispersion parameter theta
is necessary for a Negative Binomial distribution.
The var.func
function is yielded by QGlink.funcs
according to a given distribution.link model (see Example below).
Contrary to QGparams
, QGvar.exp
never uses the closed form solutions, but always compute the integrals.
This function yields the distribution variance. (numeric)
Pierre de Villemereuil & Michael B. Morrissey
QGvar.exp
, QGparams
, QGpred
, QGlink.funcs
, QGmean
, QGpsi
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 27 28 29 | ## Example using Poisson.log model
mu <- 1
va <- 0.2
vp <- 0.5
# The variance function is simply the inverse-link function
# because the variance of a Poisson is its mean
varfunc <- function(x) { exp(x) }
QGvar.dist(mu = mu, var = vp, var.func = varfunc)
# The QGlink.funcs gives a ready - to - use var.func
funcs <- QGlink.funcs(name = "Poisson.log")
# Calculating the distribution variance
vdist <- QGvar.dist(mu = mu, var = vp, var.func = funcs$var.func)
vdist # Same value as above
# Calculating the variance of the expected values
vexp <- QGvar.exp(mu = mu, var = vp, link.inv = funcs$inv.link)
# The phenotypic variance on the observed scale is then:
vexp + vdist
# This computation is automatically performed by QGparams
# but directly using the closed form solutions when available
QGparams(mu = mu, var.p = vp, var.a = va, model = "Poisson.log")
# var.obs is equal to the sum above
|
[1] 3.490343
[1] 3.490343
[1] 11.39339
[1] "Using the closed forms for a Poisson - log model."
mean.obs var.obs var.a.obs h2.obs
1 3.490343 11.39339 2.436499 0.213852
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.