I’m trying to fit parameters for a Holling type II curve for multiple prey items. This takes the form:
\frac{dP_i}{dt} = \frac{a_iP_i}{1 +\sum_j{a_jh_jP_j}}
where P_i is density of prey species i, a_i, is the “attack rate”, and h_i is the “handling time”. I have data for \frac{dP_i}{dt} and P_i, and would thus like to sample posterior distributions for parameter values for each a_i and h_i.
If there are a relatively few number of species, it might be straightforward to make dummy variables for each P and fit it that way, but this approach becomes untenable if there are many different P_i. Say we have hundreds of prey species, and we want a_i and h_i fit as random effects. Is there a way to use brms
in r to specify this?
Picturing something like this:
bf(dP ~ (a * P)/(1 + T),
a ~ (1|species),
T ~ sum(a * h * P),
h ~ (1|species),
nl = TRUE)