This function calculates the phenotypic mean on the observed scale from the latent mean and variance.
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.
Returns
This function yields the phenotypic mean on the observed scale. (numeric)
## Computing the observed mean for a probit linkQGmean(mu =0.3, var =1, link.inv = pnorm)# The theoretical expectation is1- pnorm(0,0.3, sqrt(1+1))# Or, using the QGlink.funcs functionQGmean(mu =0.3, var =1, link.inv = QGlink.funcs(name ="binom1.probit")$inv.link)## Computing the observed mean for a logarithm linkQGmean(mu =1, var =1, link.inv = exp)# The theoretical expectation isexp(1+0.5*1)# This computation is automatically performed by QGparams# but directly using the closed form solution when availableQGparams(mu =1, var.p =1, var.a =0.5, model ="Poisson.log")