gadget-framework / gadget3

TMB-based gadget implemtation
GNU General Public License v2.0
8 stars 6 forks source link

Predation likelhood - scsimple StomachContent #159

Closed lentinj closed 3 weeks ago

lentinj commented 3 weeks ago

(separating from https://github.com/gadget-framework/gadget3/issues/148 so we can park the latter)

Having a further dig there are other features of stomach contents that we don't quite do yet:

The (undocumented) digestioncoefficients parameter: $$d{p,0} + d{p,1} l^{d_{p,2}}$$... for each prey $p$ midlength $l$. This is a scaling factor applied to the model consumption before comparison. How useful would these be @vbartolino? It wouldn't be tough to implement, but they don't strike me as being very useful versus simulating the content of the stomach over time.

Per-prey length groupings: We currently consider "prey" (read: stock) & "prey length" separately. You'd have to make sure that prey length ranges don't overlap. For example for length ranges of 30..50 (imm), 50..100 (mat) & 0 for otherfood:

pred_a_stomach_obs <- expand.grid(
 stock = c('prey_imm', 'prey_mat', 'otherfood'),
 length = c(0, seq(30, 100, 10)),
 number = 0 )

I think the neatest solution is not doing this at all, and have separate likelihood components like happens in ven_rin_08.3:

pred_a_stom1_obs <- expand.grid(
 stock = c('prey_imm', 'prey_mat', 'otherfood'),
 number = 0 )

pred_a_stom2_obs <- expand.grid(  # Don't include otherfood when aggregating this one
 length = seq(30, 100, 10),
 number = 0 )
vbartolino commented 3 weeks ago

I've never used the digestioncoefficients, and certainly I won't for the ringed seal case where anyway most preys are estimated from undigested hard remains like the otoliths. In general, I suspect this might be useful with fish stomachs where certain preys take longer to digest which affects their occurrence and detection in the stomachs. For instance, cod in the Baltic feed on both benthic invertebrates like hard big isopods which take long to digest and softer preys like polychaete worms or small fish preys like sprat

Your second point (sorry if I missunderstood), what I've done in https://github.com/gadget-framework/gadget-models/blob/master/ven_rin_08.3/setup_likelihood_rin.R#L29-L57 which is also what was done in the cod-herring-sprat model is to have two separate likelihood components to inform about:

  1. predator-prey species preference, where preys are aggregated over all prey size (while predator is disaggregated by size)
  2. predator-prey size preference, where both predator and preys are disaggregated by size
lentinj commented 3 weeks ago

Yeah, I can see that an allowance for digestion rates would be a valuable thing, but as you say this would be most valuable over time, rather than only considering most recent digestion.

Exactly, a combined species & size preference likelihood component won't work beautifully atm, but the solution is to have multiple likelihood components rather than work out a way to do everything in one likelihood component.

bthe commented 3 weeks ago

Regarding the digestion rates, would it make sense to specify these as part of the likelihood function via a data transform function as opposed to defining them in the stock definition?

lentinj commented 3 weeks ago

Yes, definitely. The only wrinkle with that plan is we don't have length transforms yet - https://github.com/gadget-framework/gadget3/issues/95

I'm still unhappy with the interface though, unlike with age transforms, a length transform should really be applied as a matrix. But providing some matrix-generating code for one and not the other seems very weird.

Maybe the solution to this though is to accept a matrix in both cases, but then the dimensions of the age matrix aren't immediately obvious either (given a stock with ages 3..5, do you have a 5x5 matrix or 3x3?)

lentinj commented 3 weeks ago

I've added length transforms, and there's an example of using them to do digestioncoefficients. I still think age should be modified to take a matrix, but that can be worried about elsewhere.