Convert zero case counts to NA
(missing) if the 7-day average is above a threshold.
Source: R/preprocessing.R
apply_zero_threshold.Rd
This function aims to detect spurious zeroes by comparing the 7-day average
of the case counts to a threshold. If the 7-day average is above the
threshold, the zero case count is replaced with NA
.
Arguments
- data
A
<data.frame>
of confirmed cases (confirm) by date (date).confirm
must be numeric anddate
must be in date format. Optionally this can also have a logicalaccumulate
column which indicates whether data should be added to the next data point. This is useful when modelling e.g. weekly incidence data. See also thefill_missing()
function which helps add theaccumulate
column with the desired properties when dealing with non-daily data. If any accumulation is done this happens after truncation as specified by thetruncation
argument.- threshold
Numeric, defaults to
Inf
. Indicates if detected zero cases are meaningful by using a threshold number of cases based on the 7-day average. If the average is above this threshold at the time of a zero observation count then the zero is replaced with a missing (NA
) count and thus ignored in the likelihood.- obs_column
Character (default: "confirm"). If given, only the column specified here will be used for checking missingness. This is useful if using a data set that has multiple columns of hwich one of them corresponds to observations that are to be processed here.