Epidemic ModelingData and inference

Module 7Data-driven models

Models built from data. On a simulated surveillance system with a known truth, we separate infections from reported cases with an observation model (overdispersion, zeros, the log scale), take weekday and holiday reporting patterns apart, forecast with seasonal ARIMA and state-space models in an honest rolling-origin backtest, correct the latest days for reporting delay with a nowcast, compare machine-learning and deep-learning forecasters with simple baselines, and use large language models carefully, as readers with fixed forms and checks.

By the end you should be able to choose an observation model for case counts, remove calendar effects, run a rolling-origin backtest against simple baselines, nowcast recent days from a reporting triangle, and judge when machine learning or language models add value.

Key ideas, one per episode

  • Ep. 26Cases are a filtered, delayed, noisy view of infections; counts scatter like a negative binomial, not a Poisson.
  • Ep. 27Weekday and holiday patterns come from reporting offices: compare like with like, or model the calendar.
  • Ep. 28Seasonal ARIMA beat simple baselines with honest intervals, but every linear model struggles at turning points.
  • Ep. 29The latest days always look low because reports are late; a nowcast corrects them, if the delays stay the same.
  • Ep. 30On one year of data the simplest learner did best; test every learner with rolling origins against simple baselines.
  • Ep. 31Use language models as readers with fixed forms, simple checks and a person for the hard cases.

Textbook: Chapter 7 of T. Lazebnik, Epidemic Modeling: Principles, Algorithms, and Applications (Academic Press, 2026). The episodes and slides follow the chapter’s topics in our own words, figures and simulations; nothing is copied from the book.

The title slide of Module 7: Data-driven models

36 slides, written to be read on your own, with worked examples, “try it” boxes, our own small simulations and check-yourself questions (answers at the end). PDF, 1.1 MB.

Watch

6 short episodes for this module. Pick one from the list, and open the transcript to read along: each timestamp plays the episode from there. The narration is generated with a voice clone of Teddy, used with his permission.

Episode 26 · 2:59

Counts are not cases

Cases are not infections.

Cases are a filtered, delayed, noisy view of infections; counts scatter like a negative binomial, not a Poisson.

TranscriptEpisode 26
0:00

Counts are not cases. A dashboard says two thousand cases today. That's not the number of infections, and it isn't even an exact count of cases. Welcome to Module seven: models built from data, starting with the bridge between the epidemic and the numbers.

0:20

A simulated system with a known truth. To keep things honest, this module uses a simulated surveillance system, so we know the truth. A town of five million, two waves. One in four infections becomes a reported case, about six days after infection, once a test comes back. Over the year: about one and a half million infections, and three hundred sixty thousand cases. Cases are a filtered, delayed and noisy view of infections. The observation model describes that filter.

0:50

How noisy counts are. Start with the noise. Say we expect two thousand cases on a day. If counts were Poisson, almost every day would land between one thousand nine hundred twenty seven and two thousand seventy four. Real counts scatter far more: clusters, testing campaigns, batches of results. In our system the spread follows a negative binomial: the variance is the mean plus the mean squared over k, with k of thirty. Then the same day's ninety percent range is one thousand four hundred thirty five to two thousand six hundred forty one. Check it against the truth. Poisson ranges held the count on only forty one percent of days. Negative binomial ranges, on ninety one percent, as they should. So a jump of two hundred cases can be pure noise. Choose the observation model before you read meaning into the data.

1:38

Finding the dispersion. How do you find k? Plot the spread against the mean. Poisson is a straight line: variance equals mean. Our counts curve upward, and a fit gives k of about thirty five; the true value is thirty. Noise that grows with the mean is also why many models work on the log scale. There, a ten percent wobble looks the same at a hundred cases as at ten thousand.

2:03

Zeros. Zeros need care too. A zero can mean no cases, a closed lab, or a missing report. In our quiet weeks, with less than one expected case a day, half of the days had zero cases: just what both models predict. So before reaching for a special zero-inflated model, check whether small means already explain the zeros.

2:23

The layers of an observation model. The full observation model has more layers: what share of infections are found, how long they take to be reported, and how reporting depends on the calendar. Next: the calendar. Weekday patterns and holidays, and how to keep them from fooling you.

Interactive lab

Nowcasting and backtests

Nowcast the latest test dates of the course's simulated surveillance system from its reporting triangle, and compare simple forecasters in a rolling-origin backtest.

The course's simulated year runs in your browser: a reporting triangle, a nowcast with a delay distribution estimated from recent complete days, and a rolling-origin backtest of four simple forecasters.

Simple math

A surveillance system with a known truth

The course's simulated year: two waves in a town of 5 million; 1 in 4 infections becomes a case about 6 days later; reports arrive over two weeks. Everything runs in your browser.

Reporting triangle
N(t, d) = cases tested on day t, reported d days later

On day T you only see the cells with t + d < T: the newest test dates are incomplete.

Nowcast
nowcast(t) = arrived(t) ÷ F(T − t)

F(n): share of a day's cases reported within n days, estimated from complete test dates in a recent window.

Backtest
error = average |forecast − reported|

Rolling origins every 7 days: each forecast sees only reports up to its origin.

Last 7 days, arrived
–
Last 7 days, nowcast
–
Last 7 days, final
–
Nowcast error
–

Running…

Cases by test date

Orange: what has arrived; blue: the nowcast; dashed: the final count (if shown).

Challenges

Each one is checked on your current settings, here or in the backtest panel below.

  1. With the slow labs on, find a day where the nowcast is off by more than 30%.
  2. Still with slow labs, get the nowcast within 15% on a day between 225 and 235, changing only the delay window.
  3. In the backtest, find a horizon where repeating the last day beats the weekly mean.
  4. Get the trend × weekday forecast error below 100 cases.
Repeat the last day
–
Repeat last week
–
Weekly mean
–
Trend × weekday
–

Running…

Average miss

Reported cases per forecast day, over origins every 7 days from day 120.