Description Usage Arguments Details Author(s) References See Also Examples
The 'Ecological Models and Data in R' type-II decreasing prey function.
1 2 3 4 |
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 'P' and 'T'. |
boot |
A logical. Is the function being called for use by |
windows |
A logical. Is the operating system Microsoft Windows? |
a, h |
Capture rate and handling time. Usually items to be optimised. |
P, T |
P: Number of predators. T: Total time available |
X |
The X variable. Usually prey density. |
Y |
The Y variable. Usually the number of prey consumed. |
This implements the type-II functional response model described in detail in Bolker (2008). With the exception of P these functions are identical to those used in rogersII
.
The emdII
function solves the random predator equation using the LambertW equation (using the lambertW0
function from the lamW package), giving:
X - lambertW0(a * h * X * exp(-a * (P * T - h * X)))/(a * h)
Note that generally speaking P is determined by the experimental design and is therefore usually provided as a 'fixed' variable. When P = 1 the results should be identical to those provided by rogersII
.
This is exactly the function in Chapter 8 of Bolker (2008), which in turn presents examples from Vonesh and Bolker (2005). Users are directed there for more information.
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.
emdII_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 emdII_nll
function to optimise emdII
.
Further references and recommended reading can be found on the help page for frair_fit.
Daniel Pritchard
Vonesh JR, Bolker BM (2005) Compensatory larval responses shift trade-offs associated with predator-induced hatching plasticity. Ecology 86: 1580–1591. doi:10.1890/04-0535.
Bolker, BM (2008) Ecological Models and Data in R. Princeton University Press, Princeton, NJ.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | data(gammarus)
fitP1 <- frair_fit(eaten~density, data=gammarus,
response='emdII', start=list(a = 1.2, h = 0.015),
fixed=list(T=40/24, P=1))
fitP2 <- frair_fit(eaten~density, data=gammarus,
response='emdII', start=list(a = 1.2, h = 0.015),
fixed=list(T=40/24, P=2))
# Note that the coefficients are scaled to per prey item
coef(fitP1)
coef(fitP2)
# Should give identical answers to rogersII when P=1
rogII <- frair_fit(eaten~density, data=gammarus,
response='rogersII', start=list(a = 1.2, h = 0.015),
fixed=list(T=40/24))
coef(fitP1)
coef(rogII)
stopifnot(coef(fitP1)[1]==coef(rogII)[1])
stopifnot(coef(fitP1)[2]==coef(rogII)[2])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.