Skip to contents

Filter observations to restrict the maximum reporting delay

Usage

enw_delay_filter(obs, max_delay)

Arguments

obs

A data.frame containing at least the following variables: reference date (index date of interest), report_date (report date for observations), and confirm (cumulative observations by reference and report date).

max_delay

Numeric defaults to 20 and needs to be greater than or equal to 1 and an integer (internally it will be coerced to one using as.integer()). The maximum number of days to include in the delay distribution. Computation scales non-linearly with this setting so consider what maximum makes sense for your data carefully. Note that this is zero indexed and so includes the reference date and max_delay - 1 other days (i.e. a max_delay of 1 corresponds with no delay).

Value

A data.frame filtered so that dates by report are less than or equal the reference date plus the maximum delay.

Examples

obs <- enw_example("preprocessed")$obs[[1]]
enw_delay_filter(obs, max_delay = 2)
#>      reference_date .group report_date max_confirm location age_group confirm
#>   1:           <NA>      1  2021-07-13           0       DE       00+       0
#>   2:           <NA>      1  2021-07-14           0       DE       00+       0
#>   3:           <NA>      1  2021-07-15           0       DE       00+       0
#>   4:           <NA>      1  2021-07-16           0       DE       00+       0
#>   5:           <NA>      1  2021-07-17           0       DE       00+       0
#>  ---                                                                         
#> 118:     2021-08-20      1  2021-08-20         171       DE       00+      98
#> 119:     2021-08-20      1  2021-08-21         171       DE       00+     159
#> 120:     2021-08-21      1  2021-08-21         112       DE       00+      69
#> 121:     2021-08-21      1  2021-08-22         112       DE       00+     112
#> 122:     2021-08-22      1  2021-08-22          45       DE       00+      45
#>      cum_prop_reported delay
#>   1:               NaN    NA
#>   2:               NaN    NA
#>   3:               NaN    NA
#>   4:               NaN    NA
#>   5:               NaN    NA
#>  ---                        
#> 118:         0.5730994     0
#> 119:         0.9298246     1
#> 120:         0.6160714     0
#> 121:         1.0000000     1
#> 122:         1.0000000     0