QGmean: Compute the phenotypic mean on the observed scale

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

View source: R/source.R

Description

This function calculates the phenotypic mean on the observed scale from the latent mean and variance.

Usage

1
QGmean(mu = NULL, var, link.inv, predict = NULL, width = 10)

Arguments

mu

Latent intercept estimated from a GLMM (ignored if predict is not NULL). (numeric of length 1)

var

Latent total variance estimated from a GLMM. Usually, the sum of the estimated variances of the random effects, plus the "residual" variance. (numeric of length 1)

link.inv

Inverse function of the link function. (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 mu - width * sqrt(var) to mu + width * sqrt(var). The default value is 10, which should be sensible for most models. (numeric)

Details

This function needs the latent population mean (mu) or the marginal predicted values (predict) and the total latent variance (i.e. total latent variance var) to compute the observed phenotypic mean. To do so, it also requires the inverse function of the link function.

For example, if the link function is the natural logarithm, the inverse-link function will be the exponential. The inverse-link functions for many models are yielded by the QGlink.funcs function.

Contrary to QGparams, QGmean.obs never uses the closed form solutions, but always compute the integrals.

Value

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

Author(s)

Pierre de Villemereuil & Michael B. Morrissey

See Also

QGmvmean, QGparams, QGpred, QGlink.funcs, QGvar.dist, QGvar.exp, QGpsi

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Computing the observed mean for a probit link
QGmean(mu = 0.3, var = 1, link.inv = pnorm)
# The theoretical expectation is
1 - pnorm(0, 0.3, sqrt(1 + 1))

# Or, using the QGlink.funcs function
QGmean(mu = 0.3, var = 1, link.inv = QGlink.funcs(name = "binom1.probit")$inv.link)

## Computing the observed mean for a logarithm link
QGmean(mu = 1, var = 1, link.inv = exp)
# The theoretical expectation is
exp(1 + 0.5 * 1)

# This computation is automatically performed by QGparams
# but directly using the closed form solution when available
QGparams(mu = 1, var.p = 1, var.a = 0.5, model = "Poisson.log")

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