outbreak-info / outbreak.info

During outbreaks of emerging diseases such as COVID-19, efficiently collecting, sharing, and integrating data is critical to scientific research. outbreak.info is a resource to aggregate all this information into a single location.
https://outbreak.info/
GNU General Public License v3.0
33 stars 13 forks source link

change % positive calculation to rolling window #127

Open andrewsu opened 4 years ago

andrewsu commented 4 years ago

Consider changing % positive calculation to rolling window (e.g., over a 7-day window). As it is, it looks like % positive is based on cumulative totals of total tests and positive tests. Leads to nice smooth curves, but perhaps is a bit too robust to recent changes.

flaneuse commented 4 years ago

My opinion: I wouldn't expect any systematic periodicity to the percent positive data (unlike raw case counts), and it's pretty smooth past mid-April, so I would leave it as a daily value.

flaneuse commented 4 years ago

With the change from cumulative positivity to new positive cases per day, calculate 7 day rolling average for positivity. Also add in rolling averages for other metrics:

  1. calculate testing_positivity on the backend =
      d["testing_positivity"] = d.testing_positiveIncrease
              ? d.testing_positiveIncrease / d.testing_totalTestResultsIncrease
              : 0;
  2. Calculate 7-day rolling average (+/- 3 days, except at the edges) of testing_positivity as testing_positivity_rolling
  3. Calculate 7-day rolling average (+/- 3 days, except at the edges) of testing_hospitalizedIncrease as testing_hospitalizedIncrease
  4. Calculate 7-day rolling average (+/- 3 days, except at the edges) of testing_totalTestResultsIncrease as testing_totalTestResultsIncrease_rolling
flaneuse commented 4 years ago

Word of caution on testing_positivity_rolling: don't average the percent positivity, but rather calculate the ratio of sums. as in:

DON'T: mean(testing_positivity) DO: sum(testing_positiveIncrease)/sum(testing_totalTestResultsIncrease)