Estimate temporal coefficients of selection

Share:

Description

fs is a function which estimates the temporal covariance matrix (i.e. fluctuating selection) and the temporal mean alpha coefficients (i.e. directional selection) through a numerical maximization of a loglikelihood function.

Usage

1
fs(At, at, npar, nyear, method, control, ...)

Arguments

At

a list containing the named yearly variance-covariance matrices. Sorted by year.

at

a list containing the named yearly vectors of the estimated selection coefficients. Sorted by year.

npar

the number of parameters in the model for the estimates selection coefficients.

nyear

the number of years with estimates of selection.

method

defines what optimalization algorithm to be used in the maximization of the loglikelihood. Alternatives are: "Nelder-Mead", "BFGS" (default), "CG", "L-BFGS-B" and "SANN". Not all are applicable here. See ?optim for details.

control

a list of control parameters for the maximization of the likelihood. maxit sets the maximum number of iterations to use before convergence and reltol sets the relative threshold for improvement in the likelihood which desides whether to continue maximation or end. See ?optim for details.

...

additional arguments to be passed to optim for the maximization of the loglikelihood. See ?optim for options.

Details

fs is used internally in lmf when estimating temporal coefficients of selection, but given the right data can be executed as a standalone. The input to the arguments At and at are estimated within lmf by correctly combining estimates of coefficients and variance-covariance within each age class and year to a estimate for each year.

fs used optim for the numerical maximization of the log likelihood function lnL.M. Problems of non-positive definite matrices appearing as maximas, due to numerical rounding, are solved with nearPD, which implement the smallest possible numerical changes of some componets of the matrices to achive positive definiteness. These changes does not affect the results in any significant way.

Engen et al. 2012 describe the maximum likelihood method in details.

Value

fs returns a list containing the following components:

convergence

"yes" indicates that the numerical maximation of the likelihood successfully converged before reaching the iteration limit maxit.

iterations

the number of iterations of the function in the numerical maximation of the likelihood.

M

the estimated temporal covariance matrix (fluctuating selection).

aM

the estimated temporal mean selection coefficients.

Author(s)

Thomas Kvalnes

References

Engen, S., Saether, B.-E., Kvalnes, T. and Jensen, H. 2012. Estimating fluctuating selection in age-structured populations. Journal of Evolutionary Biology, 25, 1487-1499.

See Also

lmf, lnL.M, nearPD

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#Data set from Engen et al. 2012
data(sparrowdata)
#Fit model
lmf.1 <- lmf(formula = cbind(recruits, survival) ~ weight + tars,
               age = age, year = year, data = sparrowdata)
#Extract At and at
At <- lmf.1$At
at <- lmf.1$at
#Estimate temporal selection coefficients
flusel <- fs(At = At, at = at, npar = 3, nyear = 7, method = "BFGS",
  control = list(maxit = 500, reltol = sqrt(.Machine$double.eps)))
#View output
str(flusel)
flusel