Description Usage Arguments Details Value Author(s) See Also Examples
Function to estimate the quantitative genetics parameters on the observed scale based on estimates on the latent scale. The function yields a data.frame which includes the phenotypic mean and variance, as well as the additive genetic variance and heritability, on the observed scale.
1 2 
mu 
Latent intercept estimated from a GLMM (ignored if predict is not 
var.a 
Latent additive genetic variance estimated from a GLMM. (numeric of length 1) 
var.p 
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) 
model 
Name of the used model, i.e. distribution.link. Ignored if

width 
Parameter for the integral computation. The integral is evaluated from 
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) 
closed.form 
When available, should closed forms be used instead of integral computations? (boolean, ignored if 
custom.model 
If the model used is not available using the 
n.obs 
Number of "trials" for the "binomN" distribution. (numeric) 
cut.points 
Values for the "cut points" in the multiple threshold model ("ordinal"). Should be a vector of length equal to the number of categories plus one, starting with the value Inf and ending with the value Inf. (numeric) 
theta 
Dispersion parameter for the Negative Binomial distribution. The parameter 
verbose 
Should the function be verbose? (boolean) 
The function typically uses precise integral numerical approximation to compute quantitative genetics parameters on the observed scale, from latent estimates yielded by a GLMM. If closed form solutions for the integrals are available, it uses them if closed.form=TRUE
.
Only the most typical distribution/link function couples are implemented in the function. If you used an "exotic" GLMM, you can use the custom.model
argument. It should take the form of a list of functions. The first function should be the inverse of the link function named inv.link
, the second function should be the "distribution variance" function named var.func
and the third function should be the derivative of the inverse link function named d.inv.link
(see Example below).
Some distributions require extraarguments. This is the case for "binomN", which require the number of trials N, passed with the argument n.obs
. The distribution "negbin" requires a dispersion parameter theta
, such as the variance of the distribution is mean + mean**2/theta
(mean/dispersion parametrisation).
If fixed effects (apart from the intercept) have been included in the GLMM, they can be included as marginal predicted values, i.e. predicted values excluding the random effects, which can be calculated as the matrix product Xb where X is the design matrix and b is the vector of fixed effects estimates. To do so, provide the vector of marginal predicted values using the argument predict
. Note this can considerably slow down the algorithm, especially when no closed form is used.
Ordinal model is different from the other models, because it yields multivariate inference on the observed data scale, even though the latent scale is not multivariate. As a consequence, this model can only be accessed using the function QGparams
and has an output similar to the one of QGmvparams
.
The function yields a data.frame containing the following values:
mean.obs 
Phenotypic mean on the observed scale. 
var.obs 
Phenotypic variance on the observed scale. 
var.a.obs 
Additive genetic variance on the observed scale. 
h2.obs 
Heritability on the observed scale. 
Pierre de Villemereuil & Michael B. Morrissey
QGmvparams
, QGpred
, QGlink.funcs
, QGmean
, QGvar.dist
, QGvar.exp
, 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 30 31 32 33 34 35 36 37  ##Example using binary data
#Parameters
mu=0
va=1
vp=2
#Simulating data l = mu + a + e
lat<mu+rnorm(1000,0,sqrt(va))+rnorm(1000,0,sqrt(vpva))
y<rbinom(1000,1,pnorm(lat))
#Expected results
QGparams(mu=0,var.p=2,var.a=1,model="binom1.probit")
#Simulated results for mean and variance
mean(y)
var(y)
#Using integral approximations
QGparams(mu=0,var.p=2,var.a=1,model="binom1.probit",closed.form=FALSE)
#Note that the approximation is exactly equal to the results obtained with the closed form
#Let's create a custom model
custom=list(inv.link=function(x){pnorm(x)},
var.func=function(x){pnorm(x)*(1pnorm(x))},
d.inv.link=function(x){dnorm(x)})
QGparams(mu=0,var.p=2,var.a=1,custom.model=custom)
#Using an ordinal model (with 4 categories)
QGparams(mu=0.1,var.a=1,var.p=2,cut.points=c(Inf,0,0.5,1,Inf),model="ordinal")
#Note the slightly different output (see QGmvparams)
#Integrating over a posterior distribution
#e.g. output from MCMCglmm named "model"
#df < data.frame(mu=model$Sol[,'intercept'],va=model$VCV[,'animal'],vp=rowSums(model$VCV))
#params < apply(df,1,function(row){
# QGparams(mu=row$mu,var.a=row$va,var.p=row$vp,model="Poisson.log")
#})

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.