Predict the evolutionary response to selection on the observed scale
Predict the evolutionary response to selection on the observed scale
This function uses an assumed or measured fitness function to compute evolutionary response to selection on the observed scale. To do so a latent fitness function must be provided to the function. This fitness function is used to compute the evolutionary response on the latent scale.
vcv.P: Total phenotypic variance-covariance matrix. Usually, the sum of all the estimated variance-covariance matrices. (numeric)
fit.func: Function giving the expected fitness on the observed scale for a given latent trait (see Example). (function)
d.fit.func: Derivative of the expected fitness to the latent trait. This function should return a vector containing the partial derivative to each trait (see Example). (function)
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)
verbose: Should the function be verbose? (boolean)
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 uses the latent fitness function (fitness.func) and latent quantitative genetics parameters to compute the expected selection differential and response on the latent scale.
There is no argument to describe the model used as it is already and implicitely contained in the calculation of fit.func and d.fit.func (see Example below).
If fixed effects were included during the estimation of the quantitative genetics parameters, 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 will considerably slow down the algorithm.
The predictions can be transposed on the observed scale by using the QGmvmean function (see Example below).
Returns
The function yields a data.frame containing: - mean.lat.fitness: Average latent fitness. (numeric)
lat.grad: Latent selection gradient. (numeric)
lat.sel: Latent selection differential. (numeric)
lat.resp: Latent evolutionary response to selection. (numeric)
## Bivariate example with a binary trait and a Gaussian one# Assume a bivariate GLMM with Binomial(probit)/Gaussian distributions with:mu <- c(0,10)G <- matrix(c(0.5,0,0,1), nrow =2)P <- matrix(c(1,0,0,2), nrow =2)# Link functionsinv.links =function(vec){c(pnorm(vec[1]), vec[2])}# Creating the expected fitness function# i.e. expected fitness given a latent trait vector l# Say if the binary trait is 1, then the fitness is 0.5 * "the Gaussian trait"# But if the binary trait is 0, then the fitness is 0lat.fit <-function(mat){pnorm(mat[1,])*0.5* mat[2,]}# Derivative of the above function# This function yields a vector which elements are the derivative according to each traitd.lat.fit <-function(mat){matrix(c(dnorm(mat[1,])*0.5* mat[2,], pnorm(mat[1,])*0.5), nrow =2, byrow =TRUE)}# Predicting the latent evolutionary responsepred<- QGmvpred(mu = mu, vcv.P = P, vcv.G = G, fit.func = lat.fit, d.fit.func = d.lat.fit)# Predicting the observed evolutionary response# Current observed phenotypic meanQGmvmean(mu = mu, vcov = P, link.inv = inv.links)# Predicted observed phenotypic mean after selectionQGmvmean(mu = mu + pred$lat.resp, vcov = P, link.inv = inv.links)