EpiNow2 icon indicating copy to clipboard operation
EpiNow2 copied to clipboard

Mistake in implementation of zero_threshold in create_clean_reported_cases()

Open LloydChapman opened this issue 3 years ago • 0 comments

I think there are a couple of mistakes in the implementation of the zero_threshold for smoothing zeros in the reported case time series when the average of the preceding week's cases are above a certain threshold. In line 37 of create.R, I think it should be !is.infinite(zero_threshold) rather than is.infinite(zero_threshold), and in line 41, I think the current day's cases should be removed from the sum of the last 8 days cases before dividing by 7 to get the average cases over the last week, i.e.:

  if (!is.infinite(zero_threshold)) {
    reported_cases <-
      reported_cases[
        ,
        `:=`(average_7 = (data.table::frollsum(confirm, n = 8) - confirm) / 7)
      ]
    reported_cases <- reported_cases[
      confirm == 0 & average_7 > zero_threshold,
      confirm := as.integer(average_7)
    ][
      ,
      c("average_7") := NULL
    ]
  }

I'll open a pull request with these edits.

LloydChapman avatar Nov 16 '21 20:11 LloydChapman