Intra - Class Correlation coefficients (ICC) on the observed data scale (multivariate analysis).
Intra - Class Correlation coefficients (ICC) on the observed data scale (multivariate analysis).
Function to estimate the variance-covariance matrix of a variance component on the observed scale based on estimates on the latent scale. Contrary to the univariate function, this one cannot use the analytical closed forms and yields a list of paramaters instead of a data.frame.
vcv.P: Total phenotypic variance-covariance matrix. Usually, the sum of all the estimated variance-covariance matrices. (numeric)
models: A vector containing the names of the model used or a list which elements contain the list of the functions needed (inverse-link, distribution variance and derivative of the inverse-link). See QGlink.funcs for a complete list of model available or the naming of the list of functions. (character vector or list of lists of functions)
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)
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)
n.obs: Number of "trials" for each "binomN" distribution. (numeric, length equal to the number of "binomN" models)
theta: Dispersion parameter for the Negative Binomial distribution. The parameter theta should be such as the variance of the distribution is mean + mean^2 / theta. (numeric, length equal to the number of "negbin" models)
verbose: Should the function be verbose? (boolean)
compound: A vector of two indices, or list of such vectors (e.g. list(c(1,2), c(4,5))), providing the locations of "compound" distributions in the input (i.e. the dimensions that need to be "merged" into one in the output). The input must be ordered so that the first component (1 and 4 in the example above) is the latent trait for positive values and the second (2 and 5 in the example above) is the latent trait for the zero-component. Ignored if models is a character vector. (integer of length 2, or list of such vectors)
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 predict and values should be FALSE when the predictions should be filtered out.
Details
The function typically uses integral numerical approximation provided by the R2Cuba package to compute multivariate quantitative genetics parameters on the observed scale, from latent estimates yielded by a GLMM. It cannot use closed form solutions.
Only the most typical distribution/link function couples are implemented through the models argument. If you used an "exotic" GLMM, you can provide a list containg lists of functions corresponding to the model. The list of functions should be implemented as is the output of QGlink.funcs, i.e. three elements: the inverse link functions named inv.link, the derivative of this function named d.inv.link and the distribution variance named var.func (see Example below).
Some distributions require extra-arguments. 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). For now, the arguments n.obs and theta can be used for ONE distribution only.
If fixed effects (apart from the intercept) have been included in the GLMM, they can be included through the argument predict as a matrix of the marginal predicted values, i.e. predicted values excluding the random effects, for each trait (one trait per column of the matrix, see Example below).Note that computation can be extremely slow in that case.
Note that if "compound" distributions are included (such as "ZIPoisson.log.logit" or by using the compound argument), the output will be of lesser dimension than the input.
Returns
The function yields a list containing the following values: - mean.obs: Vector of phenotypic means on the observed scale.
vcv.P.obs: Phenotypic variance-covariance matrix on the observed scale.
vcv.comp.obs: Component variance-covariance (G-matrix - like, but broad - sense) on the observed scale.
## Example using a bivariate model (Binary trait/Gaussian trait)# Parametersmu <- c(0,1)G <- diag(c(0.5,2))M <- diag(c(0.2,1))# Maternal effect VCV matrixP <- diag(c(1,4))# Broad - sense "G-matrix" on observed data scale## Not run: QGmvicc(mu = mu, vcv.comp = G, vcv.P = P, models = c("binom1.probit", "Gaussian"))# Maternal effect VCV matrix on observed data scale## Not run: QGmvicc(mu = mu, vcv.comp = M, vcv.P = P, models = c("binom1.probit", "Gaussian"))# Reminder: the results are the same here because we have no correlation between the two traits# Defining the model "by hand" using the listlist.models = list( model1 = list(inv.link =function(x){pnorm(x)}, d.inv.link =function(x){dnorm(x)}, var.func =function(x){pnorm(x)*(1- pnorm(x))}), model2 = list(inv.link =function(x){x}, d.inv.link =function(x){1}, var.func =function(x){0}))# Running the same analysis than above## Not run: QGmvicc(mu = mu, vcv.comp = M, vcv.P = P, models = list.models)# Using predicted values# Say we have 100 individualsn <-100# Let's simulate predicted valuesp <- matrix(c(runif(n), runif(n)), ncol =2)# Note that p has as many as columns as we have traits (i.e. two)# Multivariate analysis with predicted values## Not run: QGmvicc(predict = p, vcv.comp = M, vcv.P = P, models = c("binom1.probit", "Gaussian"))# That can be a bit long to run!