hansen {ouch} | R Documentation |
Fits the Ornstein-Uhlenbeck-based Hansen model to data.
The fitting is done using optim
.
hansen(data, tree, regimes, alpha, sigma, fit = TRUE, method = c("Nelder-Mead","subplex","BFGS","L-BFGS-B"), hessian = FALSE, ...)
data |
Phenotypic data for extant species, i.e., at the terminal twigs of the phylogenetic tree.
This can either be a single numeric vector or a list (or data-frame) containing nchar vectors (columns) of data.
|
tree |
A phylogenetic tree, specified as an ouchtree object.
|
regimes |
A vector of codes, one for each node in the tree, specifying the selective regimes hypothesized to have been operative.
Corresponding to each node, enter the code of the regime hypothesized for the branch segment terminating in that node.
For the root node, because it has no branch segment terminating on it, the regime specification is irrelevant.
If there are nchar quantitative characters (i.e., if data is a list with nchar columns), then regimes should be a list length 1 or nchar .
|
alpha, sigma |
These are used to initialize the optimization algorithm. The selection strength matrix alpha and the random drift variance-covariance matrix sigma^2 are parameterized by their matrix square roots. Specifically, these initial guesses are each packed into lower-trinagular matrices (column by column). The product of this matrix with its transpose is the alpha or sigma^2 matrix. See Details, below. |
fit |
If fit=TRUE , then the likelihood will be maximized.
If fit=FALSE , the likelihood will be evaluated at the specified values of alpha and sigma ; the optima theta will be returned as well.
|
method |
The method to be used by the optimization algorithm, optim .
See subplex and optim for information on the available options.
|
hessian |
If hessian=TRUE , then the Hessian matrix will be computed by optim .
|
... |
Additional arguments will be passed as control options to optim or subplex .
See optim and subplex for information on the available options.
|
The Hansen model for the evolution of a multivariate trait X along a lineage can be written as a stochastic differential equation (Ito diffusion)
dX = alpha (theta(t)-X(t)) dt + sigma dB(t),
where t is time along the lineage, theta(t) is the optimum trait value, B(t) is a standard Wiener process (Brownian motion), and alpha and sigma are matrices quantifying, respectively, the strength of selection and random drift. Without loss of generality, one can assume sigma is lower-triangular. This is because only the infinitesimal variance-covariance matrix sigma^2 = sigma%*%transpose(sigma) is identifiable, and for any admissible variance-covariance matrix, we can choose sigma to be lower-triangular. Moreover, if we view the basic model as describing evolution on a fitness landscape, then alpha will be symmetric and if we further restrict ourselves to the case of stabilizing selection, alpha will be positive definite as well. We make these assumptions and therefore can assume that the matrix alpha has a lower-triangular square root.
The hansen
code uses numerical optimization to maximize the likelihood.
To do this, it parameterizes the alpha and sigma matrices.
Each matrix can be parameterized by nchar*(nchar+1)
parameters, where nchar
is the number of quantitative characters.
Specifically, the parameters initialized by the alpha
argument of hansen
are used to fill the nonzero entries of a lower-triangular matrix (in column-major order), which is then multiplied by its transpose to give the selection-strength matrix.
The parameters specified in sigma
fill the nonzero in the lower triangular sigma matrix.
When hansen
is executed, the numerical optimizer maximizes the likelihood over these parameters.
The print
, show
, and summary
methods for the resulting hansentree
object display (among other things) the estimated alpha and sigma^2 matrices.
The coef
method extracts a named list containing not only these matrices (given as the alpha.matrix
and sigma.sq.matrix
elements) but also the MLEs returned by the optimizer (as alpha
and sigma
, respectively).
The latter elements should not be interpreted, but can be used to restart the algorithm, etc.
hansen
returns an object of class hansentree
.
For details on the methods of that class, see hansentree
.
Aaron A. King <kingaa at umich dot edu>
Butler, M.A. and A.A. King (2004) Phylogenetic comparative analysis: a modeling approach for adaptive evolution. American Naturalist 164:683-695.