# SIR SEIR Compartmental Epidemic R0 and Intervention Modeling Coach

Run SIR / SEIR / SEIR+V / SEIR+H ODEs with RK4: R0, herd-immunity threshold, analytic peak and final-size equations, growth-rate conversion, WAIFW next-generation-matrix R0, incidence fitting and intervention simulation.

> Canonical page: https://elysiatools.com/en/tools/sir-seir-compartmental-epidemic-r0-and-intervention-modeling-coach

- **Category:** Health

- **Keywords:** sir model, seir model, r0 calculator, epidemic curve, herd immunity, final size equation, next generation matrix, intervention simulation

## Overview

A deterministic compartmental coach for learning and teaching infectious-disease dynamics.

Models: SIR, SEIR, SEIR+V (vaccination S→V) and SEIR+H (hospitalization arm I→H→R), solved with classic RK4 at a 0.05-day step. Derived quantities: R0 = β/γ, post-intervention effective R0, herd-immunity threshold 1−1/R0, analytic SIR peak I/N = 1−(1+lnR0)/R0, final size z = 1−e^(−R0·z), and the exact growth-rate relation R0 = 1+r/γ (SIR) or (1+r/σ)(1+r/γ) (SEIR, Wallinga–Lipsitch).

Optional inputs: a "day,incidence" series triggers a grid + coordinate-descent least-squares fit of (R0, reporting fraction, I0) with a log-linear growth-rate cross-check; a WAIFW matrix (e.g. "10 2; 2 1") computes the age-stratified next-generation-matrix R0 = ρ(β_ij/γ_j) by power iteration; intervention day + beta reduction, vaccination campaign, and a hospital arm with LOS show policy trade-offs on the curve.

## Inputs

- **Model** (select)
- **Population (N)** (number): 1000000
- **Basic Reproduction Number (R0)** (number): 2.5
- **Infectious Period (days)** (number): 5
- **Latent Period (days, SEIR)** (number): 3
- **Initial Infectious (I0)** (number): 10
- **Horizon (days)** (number): 180
- **Intervention Start (day)** (number): 0 = none
- **Beta Reduction (%)** (number): 0
- **Vaccination Start (day)** (number): 0 = none
- **Vaccination Rate (% of S per day)** (number): 0
- **Hospitalized Share of Infectious (%)** (number): 0
- **Hospital Length of Stay (days)** (number): 10
- **WAIFW Matrix (optional)** (textarea): e.g. 10 2; 2 1 (who-acquires-infection-from-whom, β per day)
- **Incidence Series to Fit (optional)** (textarea): day,incidence per line e.g. 1,12 2,19 3,31

## When to use

- Simulating infectious disease dynamics to project infection peaks, attack rates, and hospital bed occupancy across customizable horizons.
- Estimating the basic reproduction number (R0) and reporting rates from reported daily incidence time series using least-squares optimization.
- Evaluating the epidemiological impact of non-pharmaceutical interventions, vaccination rollouts, or structured age-contact matrices.

## How it works

- Select the compartmental model (SIR, SEIR, SEIR+V, or SEIR+H) and configure baseline parameters such as population size, R0, infectious period, and latent duration.
- Optionally enter intervention parameters (transmission beta reduction, vaccination rate, hospitalization fraction and LOS), a contact matrix (WAIFW), or empirical incidence data.
- The solver computes compartment trajectories via classic RK4 integration at a 0.05-day step size while evaluating analytic milestones and optimization routines.
- Review the interactive HTML report featuring dynamic compartment curves, effective Rt metrics, herd-immunity thresholds, and fitting diagnostics.

## Use cases

- Healthcare capacity planning to estimate peak hospitalizations and bed occupancy under varying lengths of stay.
- Epidemiological education to illustrate analytical final size relations, herd immunity thresholds, and Wallinga–Lipsitch growth conversions.
- Outbreak analysis to calibrate transmission rates (R0) and reporting fractions against observed case counts.

## Frequently asked questions

### Which numerical integration method does the simulator use?

It uses a classic 4th-order Runge-Kutta (RK4) integration algorithm solved at a fixed step size of 0.05 days.

### How are the SIR and SEIR models differentiated?

SIR transitions susceptible hosts directly to infectious status, while SEIR includes an explicit latent compartment (Exposed) parameterized by the latent period.

### How does incidence fitting estimate R0 and initial cases?

It performs grid and coordinate-descent least-squares fitting over R0, reporting fraction, and I0, accompanied by a log-linear growth-rate regression.

### What is calculated when supplying a WAIFW matrix?

The tool builds the next-generation matrix from age-stratified transmission rates and computes the spectral radius (R0) using power iteration.

### How do vaccination and hospitalization parameters alter the compartments?

SEIR-V transfers a daily percentage of susceptible individuals to a protected compartment (V), while SEIR-H diverts infectious cases into a hospital compartment (H) governed by length of stay.

## Related tools

- [Base Excess Calculator (Metabolic Component)](https://elysiatools.com/en/tools/base-excess-calculator): Calculate base excess (BE) using the Siggaard-Andersen formula. BE < −3 metabolic acidosis, > +3 metabolic alkalosis. HCO₃⁻ auto-calculated from pH + PaCO₂ if omitted. Derived from Siggaard-Andersen 1974, Cornell PICU, Medscape, and Langer 2022. Not medical advice.
- [Blood Gas Acid-Base Interpretation (AG / ΔAG)](https://elysiatools.com/en/tools/blood-gas-anion-gap): Complete ABG analysis: pH, primary disorder, compensation (Winter's formula), anion gap ± albumin correction, delta ratio for mixed disorder detection. Derived from Emmett 2016, Kraut 2007, Rastegar 2007, LITFL, MDCalc, and Adrogué 1998. Not medical advice.
- [Caprini Score (VTE Risk, 2005)](https://elysiatools.com/en/tools/caprini-score): Calculate the 2005 Caprini Risk Assessment Model to stratify venous thromboembolism (VTE) risk in surgical patients. ~40 items weighted 1/2/3/5 points: 1 point (age 41-60, minor surgery, BMI >25, swollen legs, varicose veins, pregnancy/postpartum, recurrent miscarriage, OCP/HRT, sepsis <1mo, lung disease/pneumonia <1mo, COPD, acute MI, CHF <1mo, bedridden, medical bed rest, IBD); 2 points (age 61-74, arthroscopic surgery, major open surgery >45min, laparoscopic >45min, malignancy, bed >72h, plaster cast, central line); 3 points (age ≥75, personal/family VTE history, factor V Leiden, prothrombin 20210A, lupus anticoagulant, anticardiolipin, homocysteine, HIT, other thrombophilia); 5 points (stroke <1mo, elective major lower-extremity arthroplasty, hip/pelvis/leg fracture <1mo, acute spinal cord injury <1mo, multiple trauma <1mo). Management tiers: 0 lowest, 1-4 low-moderate (mechanical), 5-6 high (consider LMWH 7-10d), 7-8 high (LMWH 7-10d), ≥9 highest (LMWH 30d). Derived from Caprini 2005. Not medical advice.
- [CHA₂DS₂-VASc Score (AFib Stroke Risk)](https://elysiatools.com/en/tools/chads2-vasc-score): Calculate the CHA₂DS₂-VASc score to stratify stroke risk in non-valvular atrial fibrillation and guide oral anticoagulation. Components: Congestive heart failure/LV dysfunction (+1), Hypertension (+1), Age ≥75 (+2), Diabetes (+1), prior Stroke/TIA/thromboembolism (+2), Vascular disease — prior MI/PAD/aortic plaque (+1), Age 65–74 (+1), Sex category female (+1). Range 0–9 (women) / 0–8 (men). Thresholds: men ≥2 or women ≥3 → recommend oral anticoagulation (DOAC preferred over warfarin); men 1 or women 2 → consider anticoagulation; men 0 or women ≤1 → omit. Female sex alone is not an independent risk factor (score 1 from sex alone is treated as 0). Includes an approximate annual stroke-risk estimate (Lip 2010 derivation cohort). Derived from Lip 2010 (Chest), 2019 AHA/ACC/HRS update, and 2023 ACC/AHA/ACCP/HRS AF guideline. Combine with bleeding risk (HAS-BLED) and shared decision-making. Not medical advice.
- [Charlson Comorbidity Index (Age-Adjusted)](https://elysiatools.com/en/tools/charlson-comorbidity-index): Calculate the Charlson Comorbidity Index (CCI), including the age-adjusted variant, to predict 1-year mortality from chronic comorbidities. 19 comorbidities are weighted by mortality risk: 1 point (MI, CHF, PVD, cerebrovascular disease, dementia, chronic pulmonary disease, connective tissue disease, peptic ulcer, mild liver disease, diabetes without complications); 2 points (hemiplegia/paraplegia, moderate-to-severe CKD, diabetes with end-organ damage, any non-metastatic tumor, leukemia, lymphoma); 3 points (moderate-to-severe liver disease); 6 points (metastatic solid tumor, AIDS). Age adjustment adds 1 point per decade ≥50 (50-59 +1 … ≥90 +5). Interpretation: 0 ~8%, 1-2 ~25%, 3-4 ~50%, ≥5 ~80-90% 1-year mortality (derivation cohort). Derived from Charlson 1987 (J Chronic Dis) and the 1994 validation. Not medical advice.
- [CURB-65 vs PSI vs SMART-COP (Pneumonia Severity Comparison)](https://elysiatools.com/en/tools/curb-65-vs-pneumonia-severity): Compare three pneumonia severity scores side-by-side from one set of inputs to support concordance reading. CURB-65 (0-5: Confusion, Urea, RR, BP, age ≥65) — quick bedside triage; PSI/PORT (Fine 1997, 5 risk classes) — the most accurate mortality stratification, more complex; SMART-COP (0-10, 2 points each for SBP <90 and hypoxia, 1 point each for multilobar CXR, albumin <3.5, RR ≥25, tachycardia ≥125, confusion, pH <7.35) — predicts need for ICU respiratory/vasopressor support. Each score has a different focus: CURB-65 is fast; PSI is more precise; SMART-COP identifies who needs ICU. The tool reports each score's total/category/interpretation and an agreement analysis (whether all three point to outpatient/admission/ICU). When scores disagree, favor the more conservative disposition. Derived from Lim 2003, Fine 1997, Charles 2008. Not medical advice.
- [Drug Accumulation Index Calculator (R = 1/(1-e^(-kτ)))](https://elysiatools.com/en/tools/drug-accumulation-index): Calculate the drug accumulation index R under repeated fixed-interval dosing with linear first-order elimination: R = 1 / (1 - e^(-kτ)), where k = ln2 / t½ and τ is the dosing interval. R is the ratio of the steady-state peak concentration to the peak concentration after the first dose — it quantifies how much the body burden rises at steady state versus a single dose. For example, dosing once per half-life (τ = t½) gives R = 2. The term e^(-kτ) is the fraction of peak concentration remaining at the end of one interval. Valid only for linear first-order elimination with fixed dose and interval — NOT for Michaelis-Menten drugs (phenytoin) or non-linear kinetics. Not medical advice.
- [HAS-BLED Score (Major Bleeding Risk)](https://elysiatools.com/en/tools/has-bled-score): Calculate the HAS-BLED score to estimate major bleeding risk in patients on oral anticoagulation (most commonly combined with CHA₂DS₂-VASc in atrial fibrillation). Each component scores 1 point: Hypertension (uncontrolled, systolic BP >160), Abnormal renal function (dialysis/transplant/Cr >2.26 mg/dL), Abnormal liver function, prior Stroke, prior major Bleeding/predisposition, Labile INR (TTR <60% on warfarin), Elderly (age >65), Drugs (antiplatelet/NSAID), Alcohol (≥8 drinks/week). Range 0–9 (renal/liver and drugs/alcohol can each contribute up to 2). Interpretation: 0 low, 1–2 moderate, ≥3 high risk — regular review and correct reversible factors; a high score alone does NOT justify withholding anticoagulation. Derived from Pisters 2010 (Chest) and the 2023 ACC/AHA/ACCP/HRS AF guideline. The 'labile INR' criterion mainly applies to warfarin users; predictive value is lower for DOACs. Not medical advice.

## Samples

- [Web Image Processing Python Samples](https://elysiatools.com/en/samples/web-image-processing-python): Web Python image processing examples using PIL/Pillow including reading, saving, resizing, and format conversion
- [Android Image Processing Java Samples](https://elysiatools.com/en/samples/android-image-processing-java): Android Java image processing examples including reading/saving images, scaling, and format conversion
- [Android Image Processing Kotlin Samples](https://elysiatools.com/en/samples/android-image-processing-kotlin): Android Kotlin image processing examples including reading/saving images, scaling, and format conversion
- [Web Image Processing Rust Samples](https://elysiatools.com/en/samples/web-image-processing-rust): Web Rust image processing examples including image read/save, scaling, and format conversion
