find.mle starts a search for the maximum likelihood (ML)
parameters from a starting point x.init. x.init should
be the correct length for func, so that func(x.init)
returns a valid likelihood. However, if func is a constrained
function (via constrain) and x.init is the
correct length for the unconstrained function then an attempt will be
made to guess a valid starting point. This will often do poorly and a
warning will be given.
Different methods will be dispatched for different types of likelihood
functions. Currently all models in diversitree are supported
(bisse, geosse, mk2, mkn, bd, and
yule). With the exception of the Yule pure-birth process, these
methods just specify different default arguments for the underlying
optimisation routines (the Yule model has an analytical solution, and no
optimisation step is required). Generally, it will not be necessary
to specify the method argument to find.mle as a sensible
method is chosen during dispatch.
The ... argument may contain additional arguments for the
function func. This includes things like condition.surv
for conditioning on survival in BiSSE, birth-death, and Yule models.
Specify this as
find.mle(lik, x.init, condition.surv=TRUE)
(see the Examples).
Different method arguments take different arguments passed
through ... to control their behaviour:
method="optim": Uses R's optim function for the
optimisation. This allows access to a variety of general purpose
optimisation algorithms. The method within optim can be
chosen via the argument optim.method, which is set to
"L-BFGS-B" by default (box constrained quasi-Newton optimisation).
This should be suitable for most uses. See the method argument
of optim for other possibilities. If "L-BFGS-B"
is used, then upper and lower bounds may be specified by the arguments
lower and upper. The argument control can be
used to specify other control parameters for the algorithms - see
optim for details. Most of the optim algorithms
require finite values be returned at every evaluated point. This is
often not possible (extreme values of parameters or particular
combinations may have zero likelihood and therefore -Inf
log-likelihood). To get around this, the argument fail.value
can be used to specify a fallback value. By default this is set to
func(x.init) - 1000, which should work reasonably well for most
cases.
method="subplex": Uses the "subplex" algorithm (a variant of
the downhill simplex/Nelder-Mead algorithm that uses Nelder-Mead on a
sequence of subspaces). This algorithm generally requires more
evaluations than optim-based optimisation, but does not require
approximation of derivatives and seems to find the global optimum more
reliably (though often less precisely). Additional arguments are
control to control aspects of the search (see
subplex for details). The argument fail.value
can be used as in method="optim", but by default -Inf
will be used on failure to evaluate, which is generally appropriate.
method="nlminb": Uses the function nlminb for
optimisation, so that optimising a Mk2/Mkn likelihood function behaves
as similarly as possible to ape's ace function.
As for method="optim", lower and upper bounds on parameters may
be specified via lower and upper. fail.value can
be used to control behaviour on evaluation failure, but like
method="subplex", -Inf is used which should work in most
cases. Additional control parameters may be passed via control
- see link{nlminb} for details. This function is not generally
recommended for use.
method="nlm": Uses the function nlm for
optimisation, so that optimising a birth-death likelihood function
behaves as similarly as possible to ape's
birthdeath function. Takes the same additional
arguments as method="nlminb" (except that fail.value
behaves as for method="optim"). Like method="nlminb",
this is not recommended for general use.
code and logLik methods exist for fit.mle objects
so that parameters and log-likelihoods may be extracted. This also
allows use with AIC.
Simple model comparison by way of likelihood ratio tests can be
performed with anova. See Examples for usage.