Tabellab
Data, tech, science & health

SIR model in Excel, step by step

An SIR model in Excel needs three columns and two rates. Every day, new infections = β × S × I ÷ N move from Susceptible to Infectious, and recoveries = γ × I move from Infectious to Recovered. Tomorrow's S, I and R are today's values plus or minus those flows, one row per day. With a transmission rate β of 0.3 per day and an 8-day infectious period (γ = 0.125), the basic reproduction number is R0 = β ÷ γ = 2.4, the herd immunity threshold is 58.3%, and the classic formulas predict that about 21.9% of the population is infectious at the peak and 87.9% is infected in the end. The sheet below builds the model for a fictional town of 100,000 people.

Updated 21 Oct 2026 6 min read By Tabellab team

The SIR model in one paragraph

The SIR model of Kermack and McKendrick (1927) splits a population of size N into three compartments: Susceptible, Infectious and Recovered (immune, or removed). People move one way only, S → I → R, and S + I + R stays equal to N. Two parameters drive everything. β is the number of effective contacts an infectious person has per day, and γ the daily recovery rate, 1 divided by the average infectious period. It is the simplest epidemic model that produces the familiar rise, peak and decline, and the starting point for SEIR and age-structured models.

Step 1: the equations as formulas

Of the β contacts an infectious person makes, only the share S ÷ N reaches someone who can still be infected. So with the parameters in B2:B5 and day 0 in row 11:

  • New infections: =$B$3*B11*C11/$B$2
  • Recoveries: =$B$4*C11
  • S tomorrow: =B11-E11
  • I tomorrow: =C11+E11-F11
  • R tomorrow: =D11+F11

Day 0 starts with I₀ = 10 infectious people and S = N − I₀ = 99,990. On day 0 the 10 infectious people cause 0.3 × 99,990 × 10 ÷ 100,000 = 3.0 new infections, and 1.25 of them recover.

Step 2: copy down one row per day

Write the formulas once in row 12 for day 1, then fill them down for 150 to 200 days. Each row is one Euler step: the differential equations of the model are approximated by daily changes. In the first two weeks the epidemic grows by about 17.5% a day, the factor 1 + β − γ, so the 10 infectious people become 95.4 by day 14, a doubling roughly every 4.3 days. Add a check column =B11+C11+D11: it must equal N in every row, otherwise a formula points at the wrong row.

Chart columns B to D against the day as an XY scatter with lines to see the curves: S falls in an S-shape, I rises to a peak and falls, R climbs to its final level. In the full version of this sheet, with the same formulas copied down to day 200, I peaks at about 22,700 people on day 58 and about 88.7% of the town is infected in the end.

Worked example: SIR model for a town of 100,000

Yellow cells are the parameters. Rows 11 to 25 are the first 15 days of the daily Euler steps. Copy row 25 down for the full epidemic. Column E iterates the final-size equation. Synthetic data.

Worked example: SIR model for a town of 100,000
ABCDEF
1ParameterValueIterationFinal size z
2Population N100,000Start1.0000
3Transmission rate β (per day)0.300Step 10.9093
4Recovery rate γ = 1 ÷ 8 days0.125Step 20.8872
5Infectious on day 0, I₀10Step 30.8811
6R0 = β ÷ γ2.40Step 40.8793
7Herd immunity threshold 1 − 1/R058.3%Step 50.8788
8Peak share infectious21.9%Step 60.8787
9
10DaySusceptible SInfectious IRecovered RNew infectionsRecoveries
11099,99010.00.03.01.3
12199,98711.71.33.51.5
13299,98313.82.74.11.7
14399,97916.24.44.92.0
15499,97419.16.55.72.4
16599,96922.48.96.72.8
17699,96226.311.77.93.3
18799,95430.914.99.33.9
19899,94536.318.810.94.5
20999,93442.723.312.85.3
211099,92150.128.715.06.3
221199,90658.934.917.67.4
231299,88969.242.320.78.6
241399,86881.250.924.310.2
251499,84395.461.128.611.9
Key formulas
  • E11=$B$3*B11*C11/$B$2New infections β × S × I ÷ N
  • C12=C11+E11-F11I tomorrow
  • B6=B3/B4R0 = β ÷ γ
  • B8=1-(1+LN(B6))/B6Peak share infectious
  • E8=1-EXP(-$B$6*E7)Final size after six iterations

Synthetic data and a textbook model. Educational only, not public-health guidance.

Step 3: R0 and the herd immunity threshold

R0 = β ÷ γ = 0.3 × 8 days = 2.4: one infectious person in a fully susceptible population infects 2.4 others over the infectious period. The epidemic grows while the effective reproduction number Rt = R0 × S ÷ N is above 1. It turns when S ÷ N falls to 1 ÷ R0, so the herd immunity threshold is 1 − 1 ÷ R0 = 58.3% immune. Vaccinating that share before an outbreak keeps Rt below 1. With an imperfect vaccine of effectiveness E, the coverage needed is the threshold divided by E.

Step 4: peak and final size without the full table

The continuous SIR model has two closed-form results. When almost everyone starts susceptible, the share infectious at the peak is 1 − (1 + LN(R0)) ÷ R0 = 21.9%. The share infected by the end, the final size z, solves z = 1 − EXP(−R0 × z). Excel has no direct function for it, but repeating the formula converges quickly: start at z = 1 and after six steps it settles at 0.8787, about 87.9%, as in column E of the example.

The daily Euler table comes out slightly higher, a peak of about 22.7% and a final size of 88.7%, because one-day steps overshoot a little. Shorter steps, for example a quarter of a day with the rates divided by 4, bring the table closer to the exact values. Note also that the final size is well above the 58.3% threshold: an unchecked epidemic overshoots herd immunity.

Beyond the basic model

Real epidemics need more. An SEIR model adds an Exposed compartment for people who are infected but not yet infectious, which delays the peak. Interventions are modelled by lowering β from a start day, which flattens and delays the curve. Fitting the model means choosing β so that the model curve matches observed cases, for example by minimising the sum of squared errors, an error measure related to the one in the MAPE guide. Births, deaths, waning immunity, age groups and reporting delays all change the results, which is why public-health models are far more detailed than this one.

Common mistakes

  • Forgetting to divide by N. β × S × I without ÷ N explodes in the first days. The contacts only infect the susceptible share of the population.
  • Referencing the same row. Tomorrow's S must use today's new infections, from the row above. A formula that refers to its own row gives a circular reference.
  • Mixing up γ and the infectious period. γ is 1 ÷ period. An 8-day period means γ = 0.125, not 8.
  • Relative references on the parameters. Copying down without $ on β, γ and N shifts them to empty cells. Lock them with $B$3, $B$4, $B$2.
  • Trusting daily steps blindly. Large β or γ with one-day steps overshoots and can even produce negative S. Use shorter steps if the rates are high.
  • Reading the model as a forecast. SIR assumes everyone mixes evenly and nothing changes. It explains dynamics, it does not predict a real outbreak.

Frequently asked questions

How do you make an SIR model in Excel?

Put N, β, γ and the starting infections in cells. In one row per day, calculate new infections as β × S × I ÷ N and recoveries as γ × I, then set the next day's S, I and R from them and copy the formulas down for 150 days or more. Chart S, I and R against the day.

How do you calculate R0 in the SIR model?

R0 = β ÷ γ, the daily transmission rate times the average infectious period. With β = 0.3 per day and an 8-day infectious period, R0 = 2.4.

What is the herd immunity threshold formula?

Herd immunity threshold = 1 − 1 ÷ R0. For R0 = 2.4 it is 58.3%. For a highly contagious disease with R0 = 15, it is about 93%.

What is the difference between SIR and SEIR?

SEIR adds an Exposed compartment for people who are infected but not yet infectious. The latent period delays and spreads out the epidemic curve compared with SIR.

Practise it in a lab

Related guides

Reading is step one. Doing is step two.

Every guide links to a lab where you build the same calculation in an online spreadsheet and get instant feedback.

Open the lab