Functions & Formulae

Each applied formula has its own function page, with a signature, implementations, and tests.

Compartment flow balance function of a compartmental model

g(x_j, f_jk, b_j, d_j) = dx_j/dt

Maps the numbers of people in the compartments of a population model, the flows between compartments per unit time and any inflow from or outflow to outside the model to the rate of change of each compartment, or, after a time step of length dt, to the next set of compartment counts. The flows can be fixed rates times compartment sizes, as in a static model, or can depend on the number infectious through the force of infection, which makes the model dynamic and nonlinear. A Markov cohort update (HE-FN-MM-001, HE-FM-MM-001) applies one fixed transition matrix to a closed cohort, the agent-based update HE-FN-ABM-001 with the per-contact infection probability HE-FM-ABM-001 follows individuals instead of pools, and a per-cycle probability from a constant rate follows HE-FM-TP-001. Reproduction numbers of the SIR model and of stratified models are in HE-FN-BRN-001 (HE-FM-BRN-001 to HE-FM-BRN-005 and HE-CF-BRN-001), and the final size of an epidemic and R_0 estimated from it are in HE-FN-ATR-001, HE-CF-ATR-001 and HE-FM-ATR-005, so none of them is restated here. Notation follows the Compartmental Model article.

  • Euler step of one compartment from its inflows, outflows, births and deaths

    x_next = x_now + (F_in - F_out + b - d) * dt

    Over a short step of length dt the number in a compartment changes by the flows into it from other compartments, less the flows out of it to other compartments, plus births or immigration into it, less deaths or emigration out of it, each held at its value at the start of the step. This is the article's balance equation for dx_j/dt advanced by one Euler step. Each internal flow leaves one compartment and enters another, so summed over all compartments the internal flows cancel and the population total changes only by births less deaths times dt, and stays fixed in a closed population (derived from the balance equation). Hethcote's endemic SIR model is a case with external flows, with births at rate mu N entering the susceptible class and deaths at rates mu S, mu I and mu R leaving the three classes, so that the population size stays constant. The SIR form of the step is HE-FM-CMPM-004.

  • Force of infection and new infection flow under frequency-dependent transmission

    lambda = beta * I / N; F_SI = lambda * S

    The force of infection is the rate at which each susceptible person is infected. Under frequency-dependent, or standard, transmission it is the transmission rate beta times the infectious proportion I/N, and new infections per unit time are lambda times S, the flow from the susceptible to the infectious compartment. The WHO guide writes the incidence as lambda X = p c (Y/N) X, so beta here corresponds to p times c, the probability of transmission per contact times the contact rate. Because lambda rises and falls with I, a model that recalculates it at every step is dynamic and one that holds it fixed, or takes it from a run without the programme, is static (HE-FM-CMPM-005). Hethcote contrasts this standard incidence with the mass action form eta I S, for which beta equals eta N, the form van den Driessche writes as beta S I with force of infection beta I. The per-person probability of infection within a step under a constant lambda follows HE-FM-TP-001.

  • Force of infection on one group from infectious people in two mixing groups

    lambda_1 = beta_11 * I_1 / N_1 + beta_12 * I_2 / N_2

    When the population is split into groups, such as age or risk groups, each compartment is stratified by group and the force of infection on susceptible people in group a sums the transmission from the infectious people of every group, each weighted by a transmission rate beta_ab and the infectious proportion I_b/N_b of group b. Written out for two groups the formula gives lambda_1, and lambda_2 follows by exchanging the indices 1 and 2. Hethcote's SEIR model with age groups writes the force of infection on group i as a contact-weighted sum over the infectious fractions of all groups, with separable contact rates, which is the case beta_ab = b_a b~_b N_b/N of the matrix form here (derived); a full matrix of beta_ab, the article's notation, allows any pattern of mixing. When beta_1b equals beta times N_b/N for both groups, mixing is random and lambda_1 reduces to beta I/N of HE-FM-CMPM-002 (derived). The reproduction number of a stratified model is the dominant eigenvalue of its next-generation matrix, HE-FM-BRN-005 and HE-CF-BRN-001.

  • One Euler step of the closed SIR model with frequency-dependent transmission

    F = beta * S * I / N * dt; G = gamma * I * dt; S_next = S - F; I_next = I + F - G; R_next = R + G

    Applies the compartment balance HE-FM-CMPM-001 to the susceptible, infectious and recovered compartments of Hethcote's classic SIR epidemic model, with new infections F from the force of infection of HE-FM-CMPM-002 and recoveries G at rate gamma, both computed from the counts at the start of the step. F leaves S and enters I, and G leaves I and enters R, so S_next plus I_next plus R_next equals S plus I plus R and the population is conserved at every step. Written as a cohort update the step has an S to I entry of beta I dt/N that changes with the infectious count, so the transition matrix differs at every step and the update is nonlinear in the state, whereas HE-FM-MM-001 applies one fixed matrix to a cohort that does not interact. Pitman and colleagues note that spreadsheet models often use this Euler method and that it is less accurate than other numerical techniques, so the step is kept short against the mean infectious period 1/gamma.

  • Infections averted in one step under a static and a dynamic force of infection

    lambda_b = beta * I_b / N; A_stat = lambda_b * (S_b - S_p) * dt; A_dyn = beta * (S_b * I_b - S_p * I_p) / N * dt; A_ind = A_dyn - A_stat

    Compares one step of a programme run with the same step of the no-programme run. The static count applies the no-programme force of infection lambda_b to the programme's susceptibles, so infections averted are lambda_b times the fall in susceptibles, the direct effect only. The dynamic count recalculates the force of infection from the programme's own infectious count, as the WHO guide describes for a dynamic model, and the difference A_ind is the indirect effect of fewer infectious people, which simplifies to beta S_p (I_b minus I_p) dt/N (derived). The two counts agree in a step that both runs start with the same infectious count and diverge once the programme has lowered I. Summed over the article's two days this gives the article's comparison, and HE-CF-CMPM-001 runs longer horizons with the static run keeping its own susceptible count, and Jit and Brisson explain why against no intervention the dynamic count is usually the larger, so that a static estimate is conservative.

Compartmental Model — Functions & Formulae | HealthEconomics.wiki