# Predict the evolutionary response to selection on the observed scale

### Description

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.

### Usage

1 2 |

### Arguments

`mu` |
Latent intercept estimated from a GLMM (set to 0 if |

`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) |

`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 (see Example). (function) |

`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 |

`verbose` |
Should the function be verbose? (boolean) |

### Details

The function uses the latent fitness function (`fit.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`

.

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 `QGmean`

function (see Example below).

### Value

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)

### Author(s)

Pierre de Villemereuil & Michael B. Morrissey

### See Also

`QGparams`

, `QGlink.funcs`

, `QGmean`

, `QGvar.dist`

, `QGvar.exp`

, `QGpsi`

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ```
##Example with binary traits and a fitness measurement
#Let's assume we dispose of a binary trait measurement
#and associated fitness of trait 0 (say 1) and trait 1 (say 1.86)
#We further assume a GLMM with Binomial distribution and probit link with:
mu=-0.1
va=2
vp=2.5 #note that the latent heritability is very high
#Creating the latent fitness function
#i.e. expected fitness given a latent trait l
#We have a trait 1 with probability pnorm(l) with fitness 1.86
#We have a trait 0 with probability (1-pnorm(l)) with fitness 1
lat.fit<-function(l){(1-pnorm(l))*1 + pnorm(l)*1.86}
#Derivate of the fitnes function
d.lat.fit<-function(l){- dnorm(l)*1 + dnorm(l)*1.86}
#Predicting the latent evolutionary response
pred<-QGpred(mu=mu,var.p=vp,var.a=va,fit.func=lat.fit,d.fit.func=d.lat.fit)
#Predicting the observed evolutionary response
#Current observed phenotypic mean
QGmean(mu=mu,var=vp,link.inv=QGlink.funcs("binom1.probit")$inv.link)
#Predicted observed phenotypic mean after selection
QGmean(mu=mu+pred$lat.resp,var=vp,link.inv=QGlink.funcs("binom1.probit")$inv.link)
``` |