Skip to content

Rt equation is inverted in the COVID spread notebook #814

Description

@danieljhkim

Description

In the Computing $R_t$ section of the COVID spread notebook, the displayed equation has the earlier four-day total in the numerator and the most recent four-day total in the denominator:

R_t = (I_{t-7} + I_{t-6} + I_{t-5} + I_{t-4})
      / (I_{t-3} + I_{t-2} + I_{t-1} + I_t)

This is inverted relative to the interpretation that values above 1 indicate growth.

The code immediately below the equation computes the ratio in the other direction:

df["Rt"] = df["ninfected"].rolling(8).apply(
    lambda x: x[4:].sum() / x[:4].sum()
)

Within the chronological eight-day window, x[:4] is the earlier period and x[4:] is the recent period, so the implementation is consistent with:

R_t = (I_{t-3} + I_{t-2} + I_{t-1} + I_t)
      / (I_{t-7} + I_{t-6} + I_{t-5} + I_{t-4})

For example, if daily infections increase from 10 in each of the earlier four days to 20 in each of the recent four days, the displayed equation gives 0.5, while the code gives 2.

Suggested change

Swap the numerator and denominator in the Markdown equation so that it matches the code and the surrounding explanation.

File: 2-Working-With-Data/07-python/notebook-covidspread.ipynb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions