Infectious disease models
Many infectious disease models are recurrences and convolutions. Each table maps model features to the code that builds them, with the tutorial that uses each. Three towns, step by step builds a renewal process, a reporting delay, a coupling and depletion into one model.
Transmission
| Model feature | Maths | Code | Tutorial |
|---|---|---|---|
| Renewal process | Recurrence(g), called as r(R; history) | Three towns | |
| Control measure from | the gain R .* measure | Three towns ramps the reduction in over six days | |
| Imported cases | add = ι, or Transform(+, TimeVarying(ι)) after depletion | Imported cases | |
| Instantaneous or effective reproduction number from a run | the infections over the pressure, as the call table gives | y ./ pressure(r, y; history), with pressure | The reproduction number from a run |
| Log reproduction number as a latent process | Recurrence([φ])(; history, add = ϵ) | Latent processes driving R_t | |
| Behavioural response to incidence | – | Transform, before Depletion | Latent processes driving R_t |
Random walks and autoregressions are recurrences, and moving averages are convolutions.
Susceptible depletion and vaccination
Within one step a hazard flow acts before a count flow, so waning comes before the day's doses.
Reporting and clinical delays
| Model feature | Maths | Code | Tutorial |
|---|---|---|---|
| Reporting delay | Convolution(w) | Three towns | |
| Clinical transitions, each with probability | Convolution per transition | Convolution(w)(O; gain = h), chained | Clinical outcomes |
| Delay that changes over time | Convolution(TimeVarying(W)), or TimeVarying(W, Primary()) | Time-varying delays and kernels | |
| Delay from a hazard on the logit scale, | Increments(1 - Survival(Derived(LogisticSum(), a, TimeVarying(γ)))) in TimeVarying(·, Primary()), with a local rule for LogisticSum | Local rules for maps | |
| Hazard | change points TimeVarying(Pair.([1; 2:(n + 1)], vcat(h[1], h))) inside Survival or a Derived kernel: the last value holds, so no padding is needed | TimeVarying docstring |
Places and groups
| Model feature | Maths | Code | Tutorial |
|---|---|---|---|
| Mixing between places or groups | Recurrence(g; coupling = K) | Spatial models | |
| Generation interval per group or pair | PerStratum(W), Pairwise(A) | Spatial models | |
| Transmission routes, such as community and funeral contacts | Recurrence(Pairwise(K₁ => g₁, K₂ => g₂)) | Spatial models | |
| Importation between patches | a share | Redistribute(K, ε) | Spatial models |
| Districts sharing a patch total | Allocate(groups, TimeVarying(PerStratum(Ī))) | Spatial models | |
| Each district's imported cases within a fixed patch total | Allocate(groups, Ī; imports = (φ, P), trace_imports = Val(true)) named split, read as trace.modifiers.split.imports with record = (:split,) | Allocate with imports | |
| A gain | Transform(*, TimeVarying(PerStratum(γ))) first in the modifiers, with add = a and no gain | Spatial models |
Branching processes and isolation
| Model feature | Maths | Code | Tutorial |
|---|---|---|---|
| Multi-type offspring, mean matrix | Recurrence([1.0]; coupling = K) | Branching processes | |
| Isolation | a thinned kernel g .* (1 .- p * b .* F) | Branching processes | |
| Isolation delay set by type | Recurrence(PerStratum(W); coupling = K) | Branching processes | |
| Contact tracing, traced and untraced types (an approximation) | a share | Recurrence(Pairwise(A)) | Branching processes |
| Isolation that starts on a set day, by infection day | Recurrence(TimeVarying(W, Primary())), seeded with start = m + 1 | Time-varying delays and kernels | |
| Branching-process extinction by generation | Recurrence([1.0]; modifiers = (Transform(G, θ),)), called as r(; history = [0.0], stop) | Branching processes |
Hospital occupancy and capacity
| Model feature | Maths | Code | Tutorial |
|---|---|---|---|
| Bed occupancy, survival | Convolution(S)(A); for a geometric stay, Recurrence([1 - δ])(; history, add = A) | Occupancy and capacity | |
| Patients moving between the pools of a ward | Recurrence([1.0]; modifiers = (Depletion(Flow(:U => :Q, c), Flow(:U => 0, r), Flow(:Q => 0, d); pools = (:U, :Q)),)) | Occupancy and capacity | |
| Bed cap, geometric stay | Transform(clamp, 0, B) | Occupancy and capacity | |
| Bed cap, any stay | Recurrence([0.0]; modifiers = (Transform(min, (B - Recent(S[2:end])) / S[1]),))(; history = [0.0], add = A), then Convolution(S) | Occupancy and capacity | |
| Isolation beds with overflow | Depletion(B, Flow(:O => 0, δ; form = Share()), Truncate(; into = :O, overflow = :stratum); pools = (:O,)) | Depletion in practice |
Seeding and forecasting
| Model feature | Maths | Code | Tutorial |
|---|---|---|---|
| Seed days returned with the run | r(R; history, include_history = true) | What a call returns | |
| Seed on an exponential growth path | exponential_history(I0, r, L) | Renewal then delay | |
| Forecast after a fit | continue | r(R; history, record = (:state,)), then r(R; state) | Forecasting |