Scaling Exponent Response, not assuming replacement
Description
Scaling exponent response (not assuming replacement) based on ideas dating back to Real (1977, at least)
Usage
1 2 3 4  flexpnr_fit(data, samp, start, fixed, boot=FALSE, windows=FALSE)
flexpnr_nll(b, q, h, T, X, Y)
flexpnr(X, b, q, h, T)

Arguments
data 
A dataframe containing X and Y. 
samp 
A vector specifying the rows of data to use in the fit. Provided by 
start 
A named list. Starting values for items to be optimised. Usually 'a' and 'h'. 
fixed 
A names list. 'Fixed data' (not optimised). Usually 'T'. 
boot 
A logical. Is the function being called for use by 
windows 
A logical. Is the operating system Microsoft Windows? 
b, q, h 
The search coefficient (b), scaling exponent (q) and the handling time (h). Usually items to be optimised. 
T 
T, the total time available. 
X 
The X variable. Usually prey density. 
Y 
The Y variable. Usually the number of prey consumed. 
Details
This combines a typeII nonreplacement functional response (i.e. a Roger's random predator equation) with a scaling exponent on the capture rate (a). This function is generalised from that described in flexp
relaxing the assumption that prey are replaced throughout the experiment.
The capture rate (a) follows the following relationship:
a = b*X^q
and then (a) is used to calculate the number of prey eaten (Ne) following the same relationship as rogersII
:
Ne=N0*(1exp(a*(Ne*hT)))
where b is a search coefficient and other coefficients are as defined in rogersII
. Because Ne appears on both side of the equation, the solution is found using Lambert's transcendental equation. FRAIR uses the lambertW0
function from the lamW package and the internal function is:
Ne < X  lambertW0(a * h * X * exp(a * (T  h * X)))/(a * h)
where X = N0. When q = 0, then a = b and the relationship collapses to traditional typeII Rogers' random predator equation. There is, therefore, a useful test on q = 0 in the summary of the fit.
None of these functions are designed to be called directly, though they are all exported so that the user can call them directly if desired. The intention is that they are called via frair_fit
, which calls them in the order they are specified above.
flexpnr_fit
does the heavy lifting and also pulls double duty as the statistic
function for bootstrapping (via boot()
in the boot package). The windows
argument if required to prevent needless calls to require(frair)
on platforms that can manage sane parallel processing.
The core fitting is done by mle2
from the bbmle
package and users are directed there for more information. mle2
uses the flexpnr_nll
function to optimise flexpnr
.
Further references and recommended reading can be found on the help page for frair_fit.
Author(s)
Daniel Pritchard
References
Real LA (1977) The Kinetics of Functional Response. The American Naturalist 111: 289–300.
See Also
frair_fit
, flexp
.
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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39  # A 'typeII' example
data(gammarus)
rogfit < frair_fit(eaten~density, data=gammarus,
response='rogersII', start=list(a = 1.2, h = 0.015),
fixed=list(T=1))
expofit < frair_fit(eaten~density, data=gammarus,
response='flexpnr', start=list(b = 1.2, q = 0, h = 0.015),
fixed=list(T=1))
## Plot
plot(rogfit)
lines(rogfit)
lines(expofit, col=2)
## Inspect
summary(rogfit$fit)
summary(expofit$fit) # No evidence that q is different from zero...
AIC(rogfit$fit)
AIC(expofit$fit) # The exponent model is *not* preferred
# A 'typeIII' example
data(bythotrephes)
rogfit < frair_fit(eaten~density, data=bythotrephes,
response='rogersII', start=list(a = 1.2, h = 0.015),
fixed=list(T=1))
expofit < frair_fit(eaten~density, data=bythotrephes,
response='flexpnr', start=list(b = 1.2, q = 0, h = 0.015),
fixed=list(T=1))
## Plot
plot(rogfit)
lines(rogfit)
lines(expofit, col=2)
## Inspect
summary(rogfit$fit)
summary(expofit$fit) # Some evidence that q is different from zero...
AIC(rogfit$fit)
AIC(expofit$fit) # The exponent model is preferred
