# Metapopulation SIR

Hi All,

I am wondering if there is any metapopulation SIR type example.

Thank you,
Zara

I am not aware of a tutorial with a metapopulation model, but one of the simplest cases would be a special case of general structured models where there’s a transmission term between two otherwise isolated SIR models:

    vector meta_SIR(real t, vector y, real beta, real gamma, int N)

real S1 = y[1];
real I1 = y[2];
real R1 = y[3];

real S2 = y[4];
real I2 = y[5];
real R2 = y[6];

vector[6] dydt;

// meta population one
dydt[1] = -(betaw/N) * S1 * I1 - (betab/N) * S1 * I2; // dS1/dt
dydt[2] = (betaw/N) * S1 * I1 - (betab/N) * S1 * I2 - gamma * I1; // dI1/dt
dydt[3] = gamma * I1; // dR1/dt

// meta population two
dydt[4] = -(betaw/N) * S2 * I2 - (betab/N) * S2 * I1;
dydt[5] = (betaw/N) * S2 * I2 - (betab/N) * S2 * I1 - gamma * I2;
dydt[6] = gamma * I2;

return dydt;
}


You could assume all transmission happens at the same rate, or as it’s formulated above assume transmission at a within- (\beta_w) and between- (\beta_b) metapopulation rates. If you can formulate an ODE metapopulation model, it should be straightforward to write a function for in Stan language and use the solvers to implement the inference in Stan. The specific formulation has nearly endless possibilities (e.g. the density dependence, modulated by N, may also be better modeled as metapopulation-specific), so it’s a matter of specifying exactly how the metapopulations interact, but the Stan implementation is not qualitatively more complex than an unstructured SIR.

1 Like

Great! Thanks

1 Like