frair_fit
is a utility function which helps users fit common non-linear predator-prey curves to integer data. It uses maximum likelihood estimation, via mle2
from the bbmle
package. The response requested must be known to FRAIR. To establish what is supported, inspect the output from frair_responses()
. All parameters listed by frair_responses()
(except X
) must be provided in either start
or fixed
and some guidance is given on the help pages for each function about what should (and should not) be optimised.
Generally speaking fitting non-linear curves to ecological datasets can be challenging. Approaches to fitting predator-prey functional response curves are described in further detail by Juliano (2001) and Bolker (2008). Many of the pitfalls (along with very sound advice) in non-linear curve fitting in general are described by Bolker et al. 2013. Users are directed there for more information.
Note that currently all fits encoded by FRAIR use the optim
optimiser with a non-default number of iterations (5000 [frair] vs. 500 [default]) and that all fits except typeI
use the 'Nelder-Mead' method (see Note). This is different from the mle2 default, which currently (bbmle v. 1.0.15) uses the 'BFGS' method.
mle2
is clever inasmuch as it will return fitted values even if inverting the Hessian matrix at the optimum fails. However, this will result in a warning along the lines of:
Warning message:
In mle2(fit, start = start, fixed = fixed, data = list(X = dat$X, :
couldn't invert Hessian
If this happens it could mean many things, but generally speaking it is indicative of a poor fit to the data. You might consider:
- Checking the data for transcription errors or outliers
- Trying different starting values
- Trying a different (simpler) curve
- Fitting the curve outside of FRAIR using another optimiser or another approach (see the Note, below)
- Collecting more data
Note that the advice given in mle2 to use the 'Nelder-Mead' method, is largely redundant because this is already the default in FRAIR (though you could try the 'BFGS' method quite safely...)
If convergence (i.e. fitting) fails for other reasons, see the manual page of optim
.