canmod / macpan2

Rebuilding https://github.com/mac-theobio/McMasterPandemic/
https://canmod.github.io/macpan2/
GNU General Public License v3.0
2 stars 0 forks source link

Hazard correction #61

Open stevencarlislewalker opened 1 year ago

stevencarlislewalker commented 1 year ago

The hazard correction from macpan1.5 assumed only per-capita flow types -- see here for documentation using the M 'flow matrix': https://canmod.github.io/macpan-book/hazard-smoothing

How do we modify this approach for macpan2, which allows absolute flows and one-sided flows? This needs to be answered before implementing hazard in macpan2.

@bbolker, this is not urgent, but if you have time to read this ticket and have words of wisdom, please see above.

bbolker commented 1 year ago

The hazard correction is based on assuming that the per capita outflow rate is constant and that only state variable that's relevant during the time step is the density of the originating compartment. (In particular, no inflows to the compartment are considered.)

If there are branching flows (i.e. more than one outflow from a box), we might want to look at the "Euler-multinomial" machinery in pomp.

For absolute flows, the rate doesn't depend on the state variables, so no correction should be applied (although we should consider how we can sensibly and efficiently implement guard-rails that will help people avoid getting themselves in trouble with ill-posed problems where the state variables go negative ...)

By one-sided flows do you mean flows in from a fake compartment? These should behave like absolute flows (i.e. no correction) because the density of the originating compartment doesn't change ... One-sided outflows should behave like regular outflows (i.e., hazard correction applies, in principle it should be computed simultaneously for all of the outflows from a compartment ...)

stevencarlislewalker commented 1 year ago

Thank you very much @bbolker.

In macpan base there were branching flows. For example here we have two flows out of E. So does this mean that the hazard correction never really applied properly?

Yes you understood what I meant by 'one-sided flows' and thanks for the clarification there.

bbolker commented 1 year ago

Possibly. (Although too much hazard correction might be better than too little ... ?) It occurs to me, since I haven't actually done the math, that multiple outflows might not matter for the deterministic case, only for the stochastic case where we need to maintain detailed balance [i.e. make sure that no individuals end up going to multiple output boxes by accident?], which is what pomp worries about

Glancing at the pomp documentation for deultermultinom I think it does matter though ...