Skip to contents

[Stable] Cleans a data frame of reported cases by replacing missing dates with 0 cases and applies an optional threshold at which point 0 cases are replaced with a moving average of observed cases. See zero_threshold for details.

Usage

create_clean_reported_cases(
  reported_cases,
  horizon,
  filter_leading_zeros = TRUE,
  zero_threshold = Inf
)

Arguments

reported_cases

A data frame of confirmed cases (confirm) by date (date). confirm must be integer and date must be in date format.

horizon

Numeric, defaults to 7. Number of days into the future to forecast.

filter_leading_zeros

Logical, defaults to TRUE. Should zeros at the start of the time series be filtered out.

zero_threshold

[Experimental] 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 then the zero is replaced with the backwards looking rolling average. If set to infinity then no changes are made.

Value

A cleaned data frame of reported cases

Author

Sam Abbott

Lloyd Chapman