
Calculate cumulative reported cases from incidence of new reports
Source:R/preprocess.R
enw_incidence_to_cumulative.Rd
Calculate cumulative reported cases from incidence of new reports
Usage
enw_incidence_to_cumulative(obs, by = c())
Arguments
- obs
A data frame containing at least the following variables:
reference date
(index date of interest),report_date
(report date for observations), andnew_confirm
(incident observations by reference and report date).- by
A character vector describing the stratification of observations. This defaults to no grouping. This should be used when modelling multiple time series in order to identify them for downstream modelling
See also
Preprocessing functions
enw_add_delay()
,
enw_add_max_reported()
,
enw_add_metaobs_features()
,
enw_assign_group()
,
enw_complete_dates()
,
enw_construct_data()
,
enw_cumulative_to_incidence()
,
enw_delay_filter()
,
enw_delay_metadata()
,
enw_extend_date()
,
enw_filter_reference_dates()
,
enw_filter_report_dates()
,
enw_latest_data()
,
enw_metadata()
,
enw_missing_reference()
,
enw_preprocess_data()
,
enw_reporting_triangle_to_long()
,
enw_reporting_triangle()
Examples
# Default reconstruct incidence
dt <- germany_covid19_hosp[location == "DE"][age_group == "00+"]
enw_cumulative_to_incidence(dt)
#> reference_date location age_group confirm report_date new_confirm delay
#> 1: 2021-04-06 DE 00+ 149 2021-04-06 149 0
#> 2: 2021-04-06 DE 00+ 289 2021-04-07 140 1
#> 3: 2021-04-06 DE 00+ 350 2021-04-08 61 2
#> 4: 2021-04-06 DE 00+ 402 2021-04-09 52 3
#> 5: 2021-04-06 DE 00+ 438 2021-04-10 36 4
#> ---
#> 12911: 2021-10-18 DE 00+ 113 2021-10-19 70 1
#> 12912: 2021-10-18 DE 00+ 142 2021-10-20 29 2
#> 12913: 2021-10-19 DE 00+ 223 2021-10-19 223 0
#> 12914: 2021-10-19 DE 00+ 387 2021-10-20 164 1
#> 12915: 2021-10-20 DE 00+ 235 2021-10-20 235 0
# Make use of maximum reported to calculate empirical daily reporting
dt <- enw_assign_group(dt)
dt <- enw_add_max_reported(dt)
enw_cumulative_to_incidence(dt)
#> reference_date .group max_confirm location age_group confirm report_date
#> 1: 2021-04-06 1 708 DE 00+ 149 2021-04-06
#> 2: 2021-04-06 1 708 DE 00+ 289 2021-04-07
#> 3: 2021-04-06 1 708 DE 00+ 350 2021-04-08
#> 4: 2021-04-06 1 708 DE 00+ 402 2021-04-09
#> 5: 2021-04-06 1 708 DE 00+ 438 2021-04-10
#> ---
#> 12911: 2021-10-18 1 142 DE 00+ 113 2021-10-19
#> 12912: 2021-10-18 1 142 DE 00+ 142 2021-10-20
#> 12913: 2021-10-19 1 387 DE 00+ 223 2021-10-19
#> 12914: 2021-10-19 1 387 DE 00+ 387 2021-10-20
#> 12915: 2021-10-20 1 235 DE 00+ 235 2021-10-20
#> cum_prop_reported new_confirm delay prop_reported
#> 1: 0.2104520 149 0 0.21045198
#> 2: 0.4081921 140 1 0.19774011
#> 3: 0.4943503 61 2 0.08615819
#> 4: 0.5677966 52 3 0.07344633
#> 5: 0.6186441 36 4 0.05084746
#> ---
#> 12911: 0.7957746 70 1 0.49295775
#> 12912: 1.0000000 29 2 0.20422535
#> 12913: 0.5762274 223 0 0.57622739
#> 12914: 1.0000000 164 1 0.42377261
#> 12915: 1.0000000 235 0 1.00000000