Description Usage Arguments Details Value Author(s) See Also Examples
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.
1 2 3 |
mu |
Vector of latent intercepts estimated from a GLMM (ignored if predict is not |
vcv.G |
Genetic additive variance-covariance matrix (a.k.a. G-matrix). (numeric) |
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 |
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).
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)
Pierre de Villemereuil & Michael B. Morrissey
QGparams
, 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 | ## 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 functions
inv.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 0
lat.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 trait
d.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 response
pred<- 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 mean
QGmvmean(mu = mu, vcov = P, link.inv = inv.links)
# Predicted observed phenotypic mean after selection
QGmvmean(mu = mu + pred$lat.resp, vcov = P, link.inv = inv.links)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.