diff --git a/articles/estimate_from_individual_data.html b/articles/estimate_from_individual_data.html index 3dcc5021..8d331930 100644 --- a/articles/estimate_from_individual_data.html +++ b/articles/estimate_from_individual_data.html @@ -175,11 +175,10 @@

Mathematical explanation for bias

Hence $$ E(\text{Total deaths})/ [ E(\text{Total deaths})+E(\text{Total -recoveries}) ] \\ -=[ \sum_{t} p \sum_j f_{j} I_{t-j} ]/[ \sum_{t} p \sum_j f_{j} -I_{t-j} + \sum_{t}(1-p) \sum_j f_{j} I_{t-j}] \\ -=[p \sum_{t} \sum_j f_{j} I_{t-j} ]/[ \sum_{t} \sum_j f_{j} I_{t-j} -] = p +recoveries}) ] \\ = [ \sum_{t} p \sum_j f_{j} I_{t-j} ]/[ \sum_{t} p +\sum_j f_{j} I_{t-j} + \sum_{t}(1-p) \sum_j f_{j} I_{t-j}] \\ = [p +\sum_{t} \sum_j f_{j} I_{t-j} ]/[ \sum_{t} \sum_j f_{j} I_{t-j} ] = +p $$

However, if delay to death fjDf_j^D @@ -207,15 +206,14 @@

Estimation linelist that we would expect to have a known outcome by this point if the outcome were fatal: E(deaths by time t)=ptjfjItj -E(\text{deaths by time }t) -= p \sum_{t} \sum_j f_{j} I_{t-j} +E(\text{deaths by time }t) = p \sum_{t} \sum_j f_{j} I_{t-j}

where pp is the CFR.

We can then rearrange the above to calculate the CFR: $$ -\text{Total deaths} = p \sum_{t} \sum_j f_{j} I_{t-j} \\ -p = \frac{\text{Total deaths}}{\sum_{t} \sum_j f_{j} I_{t-j} } +\text{Total deaths} = p \sum_{t} \sum_j f_{j} I_{t-j} \\ p = +\frac{\text{Total deaths}}{\sum_{t} \sum_j f_{j} I_{t-j} } $$

This is the calculation performed by cfr_static(), and hence this function can give us a better estimate of CFR when delays to @@ -393,10 +391,11 @@

Deaths reported but not recoveriesoutcome_recovery generated from a distribution with an infinite mean, and the above conclusions will still apply, with the same bias for the filtering approach. In -particular, we would expect: $$ -E(\text{Total deaths})/ [ E(\text{Total deaths})+E(\text{Total -recoveries}) ] \rightarrow 1 \\ -\text{as } E(\text{Total recoveries}) \rightarrow 0 +particular, we would expect:

+

$$ +E(\text{Total deaths})/ [ E(\text{Total deaths}) + E(\text{Total +recoveries}) ] \rightarrow 1 \\ \text{as } E(\text{Total recoveries}) +\rightarrow 0 $$

And hence the calculated CFR to incorrectly converge to 1 as the proportion of recoveries reported declines to 0.

@@ -406,9 +405,10 @@

Only total deaths reported

In some situations, we may have a time series of cases but not deaths. However, we can still use the earlier calculation to derive an -unbiased CFR: $$ -E(\text{Total deaths}) = p \sum_{t} \sum_j f_{j} I_{t-j} \\ -E(p) = \frac{\text{Total deaths}}{\sum_{t} \sum_j f_{j} I_{t-j} } +unbiased CFR:

+

$$ +E(\text{Total deaths}) = p \sum_{t} \sum_j f_{j} I_{t-j} \\ E(p) = +\frac{\text{Total deaths}}{\sum_{t} \sum_j f_{j} I_{t-j} } $$

We can do this in cfr using the estimate_outcomes() function to calculate the expected diff --git a/pkgdown.yml b/pkgdown.yml index 4eb70f70..052cfd7f 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -10,7 +10,7 @@ articles: estimate_static_severity: estimate_static_severity.html estimate_time_varying_severity: estimate_time_varying_severity.html software-permissions: software-permissions.html -last_built: 2024-12-05T19:33Z +last_built: 2024-12-06T00:04Z urls: reference: https://epiverse-trace.github.io/cfr/reference article: https://epiverse-trace.github.io/cfr/articles diff --git a/search.json b/search.json index f98e706f..8d33347e 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://epiverse-trace.github.io/cfr/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to cfr","title":"Contributing to cfr","text":"outlines propose change cfr.","code":""},{"path":"https://epiverse-trace.github.io/cfr/CONTRIBUTING.html","id":"making-changes","dir":"","previous_headings":"","what":"Making changes","title":"Contributing to cfr","text":"want make change, ’s good idea first file issue make sure someone team agrees ’s needed. ’ve found bug, please file issue illustrates bug minimal reprex (also help write unit test, needed). See bug report template. feature request see feature request.","code":""},{"path":"https://epiverse-trace.github.io/cfr/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"Making changes","what":"Pull request process","title":"Contributing to cfr","text":"See pull request template Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"epiverse-trace/cfr\", fork = TRUE). Install development dependencies devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"https://epiverse-trace.github.io/cfr/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"Making changes","what":"Code style","title":"Contributing to cfr","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"https://epiverse-trace.github.io/cfr/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to cfr","text":"Please note cfr project released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"https://epiverse-trace.github.io/cfr/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 cfr authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"use-case","dir":"Articles","previous_headings":"","what":"Use case","title":"Estimating disease severity while correcting for reporting delays","text":"disease outbreak underway. want know severe disease terms case fatality risk (CFR), delay cases reported, outcomes cases — whether recovery death — known. reporting delay, can accounted knowing reporting delay past outbreaks.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"what-we-have","dir":"Articles","previous_headings":"","what":"What we have","title":"Estimating disease severity while correcting for reporting delays","text":"time-series cases deaths, (cases may substituted another indicator infections time); Data distribution delays, describing probability individual die tt days initially infected.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"what-we-assume","dir":"Articles","previous_headings":"","what":"What we assume","title":"Estimating disease severity while correcting for reporting delays","text":"data reporting delays past outbreaks informative reporting delays current outbreak.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"case-and-death-data","dir":"Articles","previous_headings":"","what":"Case and death data","title":"Estimating disease severity while correcting for reporting delays","text":"Data cases deaths may obtained number publicly accessible sources, global Covid-19 dataset curated World Data, similar dataset made available R package covidregionaldata (Palmer et al. 2021), data outbreaks infections made available outbreaks. outbreak response scenario, data may also compiled shared locally. See vignette working data incidence2 working common format incidence data can help interoperability formats. cfr package requires data frame three columns, “date”, “cases”, “deaths”, giving daily number reported cases deaths. , use data first Ebola outbreak, Democratic Republic Congo 1976, included package (Camacho et al. 2014).","code":"data(\"ebola1976\") # view ebola dataset head(ebola1976) #> date cases deaths #> 1 1976-08-25 1 0 #> 2 1976-08-26 0 0 #> 3 1976-08-27 0 0 #> 4 1976-08-28 0 0 #> 5 1976-08-29 0 0 #> 6 1976-08-30 0 0"},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"obtaining-data-on-reporting-delays","dir":"Articles","previous_headings":"","what":"Obtaining data on reporting delays","title":"Estimating disease severity while correcting for reporting delays","text":"obtain disease’s onset--death distribution recent Ebola outbreak, reported Barry et al. (2018). onset--death distribution considered Gamma distributed, shape kk = 2.40 scale θ\\theta = 3.33. Note use continuous distribution , appropriate use discrete distribution instead working daily data. Note also use central estimates distribution parameter, ignoring uncertainty parameters uncertainty resulting CFR likely underestimated. forthcoming epiparameter package aims library epidemiological delay distributions, can accessed easily within workflows. See vignette using delay distributions information use distribution objects supported R prepare delay density functions.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"estimate-disease-severity","dir":"Articles","previous_headings":"","what":"Estimate disease severity","title":"Estimating disease severity while correcting for reporting delays","text":"use function cfr_static() calculate overall disease severity latest date outbreak. cfr_static() function well suited small outbreaks relatively events time period consideration relatively brief, severity unlikely changed time. understand severity changed time (e.g. following vaccination pathogen evolution), use function cfr_time_varying(). function however well suited small outbreaks requires sufficiently many cases time estimate CFR changes. can found vignette estimating disease severity varies course outbreak.","code":"cfr_static( data = ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) #> severity_estimate severity_low severity_high #> 1 0.9592 0.9295 0.9793"},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"estimate-ascertainment-ratio","dir":"Articles","previous_headings":"","what":"Estimate ascertainment ratio","title":"Estimating disease severity while correcting for reporting delays","text":"important know proportion cases outbreak ascertained muster appropriate response, estimate overall burden outbreak. Note ascertainment ratio may affected number factors. main factor low ascertainment lack (access ) testing capacity, refer reporting -reporting. estimate_ascertainment() function estimates ascertainment ratio using daily case death data, known severity disease previous outbreaks, optionally delay distribution onset--death. , estimate reporting 1976 Ebola outbreak Congo, assuming Ebola virus disease (time) baseline severity 0.7 (70% cases result deaths), based CFR values estimated later, larger datasets. use onset--death distribution Barry et al. (2018). analysis suggests 70% 83% cases reported outbreak. details can found vignette estimating proportion cases reported outbreak.","code":"# estimate reporting with a baseline severity of 70% estimate_ascertainment( data = ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33), severity_baseline = 0.7 ) #> ascertainment_estimate ascertainment_low ascertainment_high #> 1 0.7297748 0.7147963 0.7530931"},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"concept-how-reporting-delays-bias-cfr-estimates","dir":"Articles","previous_headings":"","what":"Concept: How reporting delays bias CFR estimates","title":"Estimating disease severity while correcting for reporting delays","text":"Simply dividing number deaths number cases obtain CFR naive estimator true CFR. Suppose 10 people start showing symptoms disease given day end day remain alive. Suppose next 5 days, numbers new cases continue rise reach 100 new cases day 5. However, suppose day 5, infected individuals remain alive. naive estimate CFR calculated end first 5 days zero, zero deaths total — point. say, outcomes cases (deaths) known. Even deaths begin occur, lag ascertainment case hospitalisation outcome leads consistently biased estimate. Hence, adjusting delays using appropriate delay distribution essential accurate estimates severity.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"a-brief-primer-on-distributions-in-r","dir":"Articles","previous_headings":"","what":"A brief primer on distributions in R","title":"A primer on working with delay distributions","text":"R extension packages provide rich extensive support representing working probability distributions, can seen CRAN probability distributions task view. Users might already familiar distributions related functionality — probability density function, random number generation — provided stats package loaded R started. example, Gamma distribution’s probability density function (PDF) represented stats::dgamma().","code":"# the probability density function at `x` for a Gamma distribution dgamma(x = seq(10), shape = 5, rate = 1) #> [1] 0.01532831 0.09022352 0.16803136 0.19536681 0.17546737 0.13385262 #> [7] 0.09122619 0.05725229 0.03373716 0.01891664"},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"using-delay-distribution-densities-in-cfr","dir":"Articles","previous_headings":"","what":"Using delay distribution densities in cfr","title":"A primer on working with delay distributions","text":"correct reporting delays disease severity estimation, primarily interested PDF PMF (probability mass function) distribution reporting delays cases known outcomes. refer R functions providing PDF PMF density distribution. delay distribution density must passed functions cfr_static(), cfr_time_varying(), estimate_ascertainment() via delay_density argument. can represented pseudo-code ","code":"cfr_*(data, delay_density = )"},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"preparing-delay-distribution-density-for-cfr","dir":"Articles","previous_headings":"","what":"Preparing delay distribution density for cfr","title":"A primer on working with delay distributions","text":"Importantly, cfr functions must receive delay density way density can calculated flexible number values (sequence days outbreak data). example, wrapping density function Gamma distribution within another function fixes distribution parameters accepts vector numbers, can evaluated set values specified vector. information working functions, especially anonymous functions, can found chapter Functional Programming Advanced R. Users working R > 4.1.0 can also use new syntax anonymous functions, e.g. \\(x) stats::dgamma(x, shape, scale). Note use central estimates distribution parameter, ignoring uncertainty parameters uncertainty resulting CFR likely underestimated.","code":"# wrap stats::dgamma() in a function # the Gamma distribution parameters are contained within dens_gamma() dens_gamma <- function(x) { stats::dgamma(x = x, shape = 5, scale = 1) } # check over a vector of `x` dens_gamma(x = seq(10)) #> [1] 0.01532831 0.09022352 0.16803136 0.19536681 0.17546737 0.13385262 #> [7] 0.09122619 0.05725229 0.03373716 0.01891664"},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"passing-delay-distribution-density-to-cfr-functions","dir":"Articles","previous_headings":"","what":"Passing delay distribution density to cfr functions","title":"A primer on working with delay distributions","text":"delay distribution density functions can passed, anonymous functions, cfr functions shown example data provided package Camacho et al. (2014). Parameters onset--death distribution Ebola virus disease taken Barry et al. (2018).","code":"# load package data data(\"ebola1976\") # pass function wrapping dgamma to cfr_static() cfr_static( data = ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) #> severity_estimate severity_low severity_high #> 1 0.9592 0.9295 0.9793"},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"using-other-distribution-representations","dir":"Articles","previous_headings":"","what":"Using other distribution representations","title":"A primer on working with delay distributions","text":"many R packages provide support representing probability distributions, focus two examples, distributional distcrete, show closures wrapping implemented, wrapping parameters Barry et al. (2018). Users may wish use similar packages better management distributions parameters. See CRAN probability distributions task view information distribution packages suitable different use cases.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"using-distributional","dir":"Articles","previous_headings":"Using other distribution representations","what":"Using distributional","title":"A primer on working with delay distributions","text":"Note output density(, x) list containing vector.","code":"# using {distributional} and parameters from Barry et al. 2018 dist_onset_to_death_ebola <- dist_gamma(shape = 2.40, rate = 1.0 / 3.33) # wrap function and pass it to cfr_static() # unlist() required as density(, x) is a list cfr_static( data = ebola1976, delay_density = function(x) unlist(density(dist_onset_to_death_ebola, x)) ) #> severity_estimate severity_low severity_high #> 1 0.9592 0.9295 0.9793"},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"using-distcrete","dir":"Articles","previous_headings":"Using other distribution representations","what":"Using distcrete","title":"A primer on working with delay distributions","text":"distcrete package provides support discrete distributions. , show example discrete Gamma distribution. Note density function objects encapsulated, can passed directly delay_density argument.","code":"# using {distcrete} and parameters from Barry et al. 2018 dist_onset_to_death_ebola <- distcrete( name = \"gamma\", shape = 2.40, scale = 3.33, interval = 1 ) # pass density function to cfr_static() cfr_static( data = ebola1976, delay_density = dist_onset_to_death_ebola$d ) #> severity_estimate severity_low severity_high #> 1 0.9576 0.9275 0.9782"},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"using-continuous-and-discrete-distributions","dir":"Articles","previous_headings":"","what":"Using continuous and discrete distributions","title":"A primer on working with delay distributions","text":"Note discrete distributions appropriate choice passed cfr_*(), usually working daily case death data. use continuous distributions many examples onset--death delays typically long large variance. Evaluating probability distribution function distributions discrete points (, days) similar evaluating probability mass function equivalent discrete distribution. However, note assumption may appropriate strongly peaked distributions, .e., onset--death strongly peaked low variance, difference PDF PMF likely larger average (spread distribution). , cfr functions tally estimated death counts (calculated convolving cases densities), underestimates due PDF-PMF discrepancy one end distribution help cancel overestimates end distribution.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"links-to-epiparameter","dir":"Articles","previous_headings":"","what":"Links to epiparameter","title":"A primer on working with delay distributions","text":"users can pass functions stats, can manage distribution parameters using specialised packages classes, may convenient able access parameters reported epidemiological literature curated library. forthcoming epiparameter package aims library epidemiological delay distributions. dedicated class expected similar functionality distribution classes, allowing easy definition density functions can passed cfr. pseudo-code shows might work.","code":"# NOTE: this is pseudo-code EPIPARAMETER_OBJECT <- ACCESS_DISTRIBUTION(disease, study) cfr_*(data = data, delay_density = function(x) density(, x))"},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_ascertainment.html","id":"use-case","dir":"Articles","previous_headings":"","what":"Use case","title":"Estimating the proportion of cases that are ascertained during an outbreak","text":"ascertainment cases outbreak perfect. want estimate proportion cases ascertained given case death data.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_ascertainment.html","id":"what-we-have","dir":"Articles","previous_headings":"","what":"What we have","title":"Estimating the proportion of cases that are ascertained during an outbreak","text":"time-series cases deaths, (cases may substituted another indicator infections time); Data distribution delays, describing probability individual die tt days initially infected.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_ascertainment.html","id":"ascertainment-for-the-covid-19-pandemic-in-the-u-k-","dir":"Articles","previous_headings":"","what":"Ascertainment for the Covid-19 pandemic in the U.K.","title":"Estimating the proportion of cases that are ascertained during an outbreak","text":"example shows ascertainment ratio estimation using cfr data Covid-19 pandemic United Kingdom. load example Covid-19 daily case death data provided cfr package covid_data, subset first six months U.K. data. obtain appropriate distribution reported Linton et al. (2020); log-normal distribution μ\\mu = 2.577 σ\\sigma = 0.440. Note Linton et al. (2020) fitted discrete lognormal distribution — use continuous distribution . See vignette delay distributions using continuous instead discrete distribution acceptable, using discrete distributions cfr. Note use central estimates distribution parameter, ignoring uncertainty parameters uncertainty resulting CFR likely underestimated.","code":"# get Covid data provided with the package data(\"covid_data\") # filter for the U.K df_covid_uk <- filter( covid_data, country == \"United Kingdom\", date <= \"2020-06-30\" ) # view the data format tail(df_covid_uk) #> date country cases deaths #> 175 2020-06-25 United Kingdom 883 97 #> 176 2020-06-26 United Kingdom 777 101 #> 177 2020-06-27 United Kingdom 726 108 #> 178 2020-06-28 United Kingdom 666 79 #> 179 2020-06-29 United Kingdom 653 73 #> 180 2020-06-30 United Kingdom 449 70"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_ascertainment.html","id":"estimating-the-proportion-of-cases-that-have-been-ascertained","dir":"Articles","previous_headings":"Ascertainment for the Covid-19 pandemic in the U.K.","what":"Estimating the proportion of cases that have been ascertained","title":"Estimating the proportion of cases that are ascertained during an outbreak","text":"use estimate_ascertainment() function calculate static CFR (internally), overall ascertainment Covid-19 pandemic U.K. assume “true” CFR Covid-19 0.014 (.e. 1.4%) (Verity et al. 2020). Future plans package include ability incorporate uncertainty CFR estimates calculating -ascertainment. Note CFR Verity et al. (2020) based lab-confirmed clinically diagnosed cases Wuhan, China. Since case definition U.K. different used , ascertainment ratio estimated likely biased. Furthermore, ignoring uncertainty estimate, ascertainment ratio likely -precise well.","code":"# static ascertainment on data estimate_ascertainment( data = df_covid_uk, delay_density = function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440), severity_baseline = 0.014 ) #> ascertainment_estimate ascertainment_low ascertainment_high #> 1 0.06779661 0.06734007 0.06829268"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_ascertainment.html","id":"ascertainment-in-countries-with-large-early-covid-19-pandemics","dir":"Articles","previous_headings":"","what":"Ascertainment in countries with large early Covid-19 pandemics","title":"Estimating the proportion of cases that are ascertained during an outbreak","text":"Finally, estimate ascertainment countries least 100,000 reported Covid-19 deaths 2020 2023, focus period start outbreak 1st June 2020. now use larger dataset covid_data made available cfr package. exclude four countries provide weekly data (zeros dates ), plot ascertainment country remaining. Example plot ascertainment ratio country early stages Covid-19 pandemic.","code":"# countries with weekly reporting weekly_reporting <- c(\"France\", \"Germany\", \"Spain\", \"Ukraine\") # subset for early covid outbreaks covid_data_early <- filter( covid_data, date < \"2020-06-01\", !country %in% weekly_reporting ) # nest the data df_reporting <- nest(covid_data_early, .by = country) # define density function delay_density <- function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440) # calculate the reporting rate in each country using # map on nested dataframes df_reporting <- mutate( df_reporting, reporting = map( .x = data, .f = estimate_ascertainment, # arguments to function severity_baseline = 0.014, delay_density = delay_density ) ) #> Total cases = 405843 and p = 0.0171: using Poisson approximation to binomial likelihood. #> Total cases = 30967 and p = 0.0433: using Poisson approximation to binomial likelihood. #> Total cases = 163103 and p = 0.031: using Poisson approximation to binomial likelihood. # unnest the data df_reporting <- unnest(df_reporting, cols = \"reporting\") # visualise the data head(df_reporting) #> # A tibble: 6 × 5 #> country data ascertainment_estimate ascertainment_low ascertainment_high #> #> 1 Argentina 0.130 0.124 0.137 #> 2 Brazil 0.112 0.111 0.113 #> 3 Colombia 0.236 0.222 0.252 #> 4 India 0.253 0.247 0.260 #> 5 Indonesia 0.153 0.146 0.161 #> 6 Iran 0.215 0.211 0.219 df_reporting %>% ggplot() + geom_pointrange( aes( x = fct_reorder(country, ascertainment_estimate), y = ascertainment_estimate, ymin = ascertainment_low, ymax = ascertainment_high ) ) + coord_flip() + labs(x = NULL, y = \"Ascertainment ratio\") + theme(legend.position = \"none\") + scale_y_continuous( labels = percent, limits = c(0, 1) ) + theme_classic() + theme(legend.position = \"top\")"},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"use-case","dir":"Articles","previous_headings":"","what":"Use case","title":"Estimating fatality risk from individual level data","text":"want estimate case fatality risk (CFR) individual-level linelist data.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"what-we-have","dir":"Articles","previous_headings":"","what":"What we have","title":"Estimating fatality risk from individual level data","text":"linelist case onset timings, well either individual outcome (.e. death, recovery) occurred point recorded, total deaths. Data distribution delay onset--death, describing probability individual die tt days initially infected.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"estimation-based-on-cases-with-known-outcomes","dir":"Articles","previous_headings":"","what":"Estimation based on cases with known outcomes","title":"Estimating fatality risk from individual level data","text":"individual-level data case onset timings outcomes, available, common filter data focus cases known outcomes. means case fatality risk can calculated filtered dataset containing known outcomes: Total deathsTotal deaths+Total recoveries \\frac{\\text{Total deaths}}{\\text{Total deaths}+ \\text{Total recoveries}} One limitation method implicitly assumes delay onset--death onset--recovery (see mathematical proof). delays noticeably different, calculation produce biased estimate CFR. example, onset--recovery much longer onset--death, given time point mid-outbreak, denominator underestimate true number cases eventually recover similar onset timings eventually die. Hence calculation inflate CFR estimate. mathematical explanation , next section discuss estimation methods based expected number known death outcomes using functionality cfr.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"mathematical-explanation-for-bias","dir":"Articles","previous_headings":"Estimation based on cases with known outcomes","what":"Mathematical explanation for bias","title":"Estimating fatality risk from individual level data","text":"linelist known outcomes onset-death delay follows distribution onset-recovery, CFR = pp, current time, E(Total deaths date)=∑tp∑jfjIt−j E(\\text{Total deaths date}) = \\sum_{t} p \\sum_j f_{j} I_{t-j} E(Total recoveries date)=∑t(1−p)∑jfjIt−j E(\\text{Total recoveries date}) = \\sum_{t}(1-p) \\sum_j f_{j} I_{t-j} ItI_t number new symptomatic infections day tt fif_i probability outcome ii days symptom onset. Hence $$ E(\\text{Total deaths})/ [ E(\\text{Total deaths})+E(\\text{Total recoveries}) ] \\\\ =[ \\sum_{t} p \\sum_j f_{j} I_{t-j} ]/[ \\sum_{t} p \\sum_j f_{j} I_{t-j} + \\sum_{t}(1-p) \\sum_j f_{j} I_{t-j}] \\\\ =[p \\sum_{t} \\sum_j f_{j} I_{t-j} ]/[ \\sum_{t} \\sum_j f_{j} I_{t-j} ] = p $$ However, delay death fjDf_j^D different delay recovery fjRf_j^R, : E(Total deaths)/[E(Total deaths)+E(Total recoveries)]=∑t∑jpfjDIt−j∑t∑jpfjDIt−j+∑t∑j(1−p)fjRIt−j E(\\text{Total deaths})/ [ E(\\text{Total deaths})+E(\\text{Total recoveries}) ] = \\frac{\\sum_{t} \\sum_j p f_j^D I_{t-j}}{\\sum_{t} \\sum_j p f_j^D I_{t-j} + \\sum_{t} \\sum_j (1-p) f_j^R I_{t-j}} hence simplify provide unbiased estimate pp, fjD=fjRf_j^D = f_j^R.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"estimation-based-on-expected-number-of-known-death-outcomes","dir":"Articles","previous_headings":"","what":"Estimation based on expected number of known death outcomes","title":"Estimating fatality risk from individual level data","text":"delay onset--death onset--recovery different, one option use survival analysis methods estimate relative hazards (.e. fatality risk) time. However, interested overall estimate CFR, simpler alternative first calculate number cases linelist expect known outcome point outcome fatal: E(deaths time t)=p∑t∑jfjIt−j E(\\text{deaths time }t) = p \\sum_{t} \\sum_j f_{j} I_{t-j} pp CFR. can rearrange calculate CFR: $$ \\text{Total deaths} = p \\sum_{t} \\sum_j f_{j} I_{t-j} \\\\ p = \\frac{\\text{Total deaths}}{\\sum_{t} \\sum_j f_{j} I_{t-j} } $$ calculation performed cfr_static(), hence function can give us better estimate CFR delays death recovery .","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"simulated-comparison-of-above-methods","dir":"Articles","previous_headings":"","what":"Simulated comparison of above methods","title":"Estimating fatality risk from individual level data","text":"compare methods, .e. filtering cases without known outcomes vs using cfr_static function, first simulate 1000 case onset timings outcomes (.e. deaths recoveries) Individual level timings onsets outcomes, individuals known outcome 20th Jan 2024. First, calculate CFR filtering focus cases known outcomes: Next, calculate CFR based expected fatal outcomes known date, using cfr_static() Hence particular simulation, cfr_static() method recovers correct CFR 10% (95% CI: 8.3-12.0%), whereas filtering method produces biased estimate 26.4% (17.6-37.0%).","code":"# Simulate data nn <- 1e3 # Number of cases to simulate pp <- 0.1 # Assumed CFR set.seed(10) # Set seed for reproducibility # Generate random case onset timings in Jan & Feb 2024 case_onsets <- as.Date(\"2024-01-01\") + sample(1:60, nn, replace = TRUE) # Define current date of data availability (i.e. max follow up) max_obs <- as.Date(\"2024-01-20\") # Sample delays from onset to outcome # 1. Deaths: assume mean delay = 5 days, sd = 5 days log_param <- c(meanlog = 1.262864, sdlog = 0.8325546) delay_death <- function(x) { dlnorm(x, meanlog = log_param[[\"meanlog\"]], sdlog = log_param[[\"sdlog\"]] ) } outcome_death <- round(rlnorm(round(nn * pp), meanlog = log_param[[\"meanlog\"]], sdlog = log_param[[\"sdlog\"]] )) # 2. Recoveries: assume mean delay = 15 days, sd = 5 days log_param <- c(meanlog = 2.65537, sdlog = 0.3245928) outcome_recovery <- round(rlnorm(round(nn * (1 - pp)), meanlog = log_param[[\"meanlog\"]], sdlog = log_param[[\"sdlog\"]] )) # Create vector of outcome dates all_outcomes <- case_onsets + c(outcome_death, outcome_recovery) # Create vector of outcome types type_outcome <- c(rep(\"D\", length(outcome_death)), rep(\"R\", length(outcome_recovery))) # Create vector of known outcomes as of max_obs known_outcomes <- type_outcome known_outcomes[(all_outcomes > max_obs)] <- \"\" # Create a data frame with onset and outcome dates, and outcome type data <- data.frame( id = 1:nn, case_onsets = case_onsets, outcome_dates = all_outcomes, outcome_type = type_outcome, known_outcome = known_outcomes ) # Filter out unknown outcomes (after the max_obs date) data <- data %>% filter(known_outcome != \"\") # Arrange data by onset date data <- data %>% arrange(case_onsets) %>% mutate(id_ordered = row_number()) # Assign a new 'id_ordered' # Prepare data for plotting (onset and outcome events in same column) plot_data <- data %>% tidyr::pivot_longer( cols = c(case_onsets, outcome_dates), names_to = \"event_type\", values_to = \"date\" ) %>% mutate( event_label = ifelse(event_type == \"case_onsets\", \"Onset\", \"Outcome\") ) # Create plot with lines linking onset and outcome ggplot() + geom_segment( data = data, aes(x = case_onsets, xend = outcome_dates, y = id_ordered, yend = id_ordered), color = ifelse(data$outcome_type == \"D\", \"red\", \"green\"), size = 0.5 ) + geom_point(data = plot_data, aes(x = date, y = id_ordered, color = outcome_type, shape = event_label), size = 2) + geom_vline(xintercept = as.numeric(max_obs), linetype = \"dashed\", color = \"black\", size = 0.5) + scale_color_manual(values = c(D = \"darkred\", R = \"darkgreen\")) + scale_shape_manual(values = c(Onset = 16, Outcome = 17)) + labs( x = \"Date\", y = \"Individual (Ordered by onset date)\", color = \"Outcome type\", shape = \"Event type\" ) + theme_minimal() #> Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. #> ℹ Please use `linewidth` instead. #> This warning is displayed once every 8 hours. #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was #> generated. # Filter on known outcomes total_deaths <- sum(known_outcomes == \"D\") total_outcomes <- (total_deaths + sum(known_outcomes == \"R\")) # Calculate CFR with 95% CI cfr_filter <- binom.test(total_deaths, total_outcomes) cfr_estimate <- (signif(as.numeric(c(cfr_filter$estimate, cfr_filter$conf.int)), 3)) cfr_estimate #> [1] 0.264 0.176 0.370 # Get times of death for fatal outcomes death_times <- (case_onsets)[type_outcome == \"D\"] + outcome_death # Create a single data.frame with event types events <- data.frame( dates = c(case_onsets, death_times), event = c(rep(\"cases\", length(case_onsets)), rep(\"deaths\", length(death_times))) ) # Use incidence2 to calculate counts of cases and deaths by day counts <- incidence2::incidence(events, date_index = \"dates\", groups = \"event\", complete_dates = TRUE) # Pivot incidence object to get data.frame with counts for cases and deaths df <- counts %>% tidyr::pivot_wider(names_from = event, values_from = count, values_fill = 0) %>% dplyr::rename(date = date_index) cfr_static(df, delay_death) #> severity_estimate severity_low severity_high #> 1 0.1042 0.086 0.1245"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"deaths-reported-but-not-recoveries","dir":"Articles","previous_headings":"","what":"Deaths reported but not recoveries","title":"Estimating fatality risk from individual level data","text":"extreme scenario recoveries reported, effectively values outcome_recovery generated distribution infinite mean, conclusions still apply, bias filtering approach. particular, expect: $$ E(\\text{Total deaths})/ [ E(\\text{Total deaths})+E(\\text{Total recoveries}) ] \\rightarrow 1 \\\\ \\text{} E(\\text{Total recoveries}) \\rightarrow 0 $$ hence calculated CFR incorrectly converge 1 proportion recoveries reported declines 0.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"only-total-deaths-reported","dir":"Articles","previous_headings":"","what":"Only total deaths reported","title":"Estimating fatality risk from individual level data","text":"situations, may time series cases deaths. However, can still use earlier calculation derive unbiased CFR: $$ E(\\text{Total deaths}) = p \\sum_{t} \\sum_j f_{j} I_{t-j} \\\\ E(p) = \\frac{\\text{Total deaths}}{\\sum_{t} \\sum_j f_{j} I_{t-j} } $$ can cfr using estimate_outcomes() function calculate expected number cases known fatal outcomes denominator: , produces point estimate 10.4%, underlying method: internal function code cfr_static(), calls estimate_outcomes(), also tallies total death. arguably elegant approach therefore add total deaths case data.frame, use input cfr_static():","code":"# Calculate total deaths and total cases total_deaths <- sum(df$deaths) total_cases <- sum(df$cases) # Create data.frame with cases over time only df_case <- df df_case$deaths <- 0 # Calculate the expected number of known fatal outcomes over time e_outcomes <- estimate_outcomes(df_case, delay_death) # Calculate the CFR total_deaths / (total_cases * tail(e_outcomes$u_t, 1)) #> [1] 0.1042066 # Create data.frame with cases over time only df_cases <- df df_cases$deaths <- 0 # Add total deaths to the final row in the 'deaths' column df_cases$deaths[nrow(df_cases)] <- sum(df$deaths) # Calculate CFR cfr_static(df_cases, delay_death) #> severity_estimate severity_low severity_high #> 1 0.1042 0.086 0.1245"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"only-total-cases-and-deaths-reported","dir":"Articles","previous_headings":"","what":"Only total cases and deaths reported","title":"Estimating fatality risk from individual level data","text":"total cases total deaths known, possible adjust delays outcome. However, can bound estimate CFR two extreme scenarios. First, outbreak , sufficient time passed fatal outcomes now known, .e. ∑t∑jfjIt−j=∑tIt \\sum_{t} \\sum_j f_{j} I_{t-j} = \\sum_{t} I_t CFR equal : p=Total deathsTotal cases p = \\frac{\\text{Total deaths}}{\\text{Total cases}} contrast, epidemic rapidly growing still early stages, even epidemic CFR 1 may generated small number fatal outcomes date. Hence following bounds possible CFR: Total deathsTotal cases≤p≤1 \\frac{\\text{Total deaths}}{\\text{Total cases}} \\leq p \\leq 1 words, rapidly growing epidemic, can say CFR lies somewhere ratio total deaths total cases (last known count) 1 (worst-case scenario).","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"use-case","dir":"Articles","previous_headings":"","what":"Use case","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"want static estimate severity outbreak form case fatality risk (CFR) correcting delay reporting outcomes cases.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"what-we-have","dir":"Articles","previous_headings":"","what":"What we have","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"time-series cases deaths, (cases may substituted another indicator infections time); Data distribution delays, describing probability individual die tt days initially infected.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"severity-of-the-1976-ebola-outbreak","dir":"Articles","previous_headings":"","what":"Severity of the 1976 Ebola Outbreak","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"example data comes 1976 Ebola virus disease (EVD, Ebola) outbreak Democratic Republic Congo (Camacho et al. 2014). focus roughly first half dataset, subsetting data include days 30th September, 1976.","code":"data(\"ebola1976\") # view the first few rows head(ebola1976) #> date cases deaths #> 1 1976-08-25 1 0 #> 2 1976-08-26 0 0 #> 3 1976-08-27 0 0 #> 4 1976-08-28 0 0 #> 5 1976-08-29 0 0 #> 6 1976-08-30 0 0 df_ebola_subset <- filter(ebola1976, date <= \"1976-09-30\")"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"onset-to-death-delay-distribution","dir":"Articles","previous_headings":"Severity of the 1976 Ebola Outbreak","what":"Onset-to-death delay distribution","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"retrieve parameters distribution durations (also called delays) onset EVD symptoms death literature (Barry et al. 2018). Gamma distribution shape kk = 2.40 scale θ\\theta = 3.33. Note shall use continuous distribution , appropriate use discrete distribution instead working daily data. See vignette delay distributions using continuous instead discrete distribution acceptable, using discrete distributions cfr. Note also use central estimates distribution parameter, ignoring uncertainty parameters uncertainty resulting CFR likely underestimated.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"intermediate-step-estimating-cases-with-known-outcomes","dir":"Articles","previous_headings":"Severity of the 1976 Ebola Outbreak","what":"Intermediate step: Estimating cases with known outcomes","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"function estimate_outcomes() estimates number cases whose outcomes expected known day ii outbreak, given time-series case onsets distribution delays symptom onset case outcome. context CFR estimation, delay distribution usually ‘onset--death’ distribution. resulting data frame contains two new columns, “estimated_outcomes”, number cases whose outcomes expected known day, “u_t” ratio cumulative number cases estimated known outcomes cumulative number cases reported date specified data. estimated outcomes lower number cases beginning outbreak case outcomes likely become known days later; also means u_t likely lower 1.0 early outbreak. u_t outbreak ended much closer 1.0, outcomes reported cases expected known (depending quality outbreak monitoring). depends distribution delays onset outcome, ratio u_t ‘catch ’ 1.0 faster onset--outcome delay short. Note period onset death may shorter period onset full recovery, considered equivalent. CFR estimation, primarily interested former goal estimating severity form fatality risk (ratio past outbreaks). Note estimate_outcomes() exported primarily intended internal use.","code":"# calculate known death outcomes df_estimated_outcomes_ebola <- estimate_outcomes( data = df_ebola_subset, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) # print head of data frame head(df_estimated_outcomes_ebola) #> date cases deaths estimated_outcomes u_t #> 1 1976-08-25 1 0 0.00000000 0.00000000 #> 2 1976-08-26 0 0 0.03323030 0.03323030 #> 3 1976-08-27 0 0 0.06494676 0.09817706 #> 4 1976-08-28 0 0 0.08485286 0.18302992 #> 5 1976-08-29 0 0 0.09400738 0.27703731 #> 6 1976-08-30 0 0 0.09515185 0.37218916 # print tail of data frame tail(df_estimated_outcomes_ebola) #> date cases deaths estimated_outcomes u_t #> 32 1976-09-25 11 8 7.787856 0.5283224 #> 33 1976-09-26 7 11 8.301252 0.5563894 #> 34 1976-09-27 7 7 8.625233 0.5840532 #> 35 1976-09-28 4 13 8.761617 0.6207698 #> 36 1976-09-29 4 12 8.659704 0.6552761 #> 37 1976-09-30 3 9 8.371787 0.6904737"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"estimating-the-naive-and-corrected-cfr","dir":"Articles","previous_headings":"Severity of the 1976 Ebola Outbreak","what":"Estimating the naive and corrected CFR","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"function cfr_static() wraps internal function estimate_outcomes() provide static CFR automatically correcting reporting delays delay density function provided.","code":"# calculating the naive CFR cfr_static( data = df_ebola_subset ) #> severity_estimate severity_low severity_high #> 1 0.7197802 0.6485503 0.7836984 # calculating the corrected CFR cfr_static( df_ebola_subset, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) #> severity_estimate severity_low severity_high #> 1 NA NA NA"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"severity-estimation-methods","dir":"Articles","previous_headings":"","what":"Severity estimation methods","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"cfr_static() automatically chooses method calculating severity estimate, based whether delay correction applied, delay correction applied, depending total number cases initial rough estimate severity. Naive estimate: delay correction applied, CFR ratio total deaths total cases, confidence interval given Binomial test using stats::binom.test() total deaths successes, total cases trials, hypothesised success 1.0 Delay correction, small outbreaks: outbreaks total cases user-specified ‘Poisson threshold’ (poisson_threshold, default = 100), CFR uncertainty around taken profile likelihood generated Binomial model deaths (successes) estimated known outcomes (trials). Delay correction, large outbreaks low severity: outbreaks total cases greater Poisson threshold (default = 100) initial severity estimates < 0.05, CFR uncertainty taken Poisson approximation Binomial profile likelihood (taking λ\\lambda = npnp nn estimated outcomes pp severity estimate). Delay correction, large outbreaks higher severity: outbreaks total cases greater Poisson threshold (default = 100) initial severity estimates ≥\\geq 0.05, CFR uncertainty taken Normal approximation Binomial profile likelihood.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"severity-of-the-covid-19-pandemic-in-the-u-k-","dir":"Articles","previous_headings":"","what":"Severity of the COVID-19 pandemic in the U.K.","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"example shows static severity estimation using cfr data Covid-19 pandemic United Kingdom. load example Covid-19 daily case death data provided cfr package covid_data, subset first year U.K. data.","code":"# get Covid data loaded with the package data(\"covid_data\") # filter for the U.K df_covid_uk <- filter( covid_data, country == \"United Kingdom\", date <= \"2020-12-31\" ) # View the first few rows and recall necessary columns: date, cases, deaths head(df_covid_uk) #> date country cases deaths #> 1 2020-01-03 United Kingdom 0 0 #> 2 2020-01-04 United Kingdom 0 0 #> 3 2020-01-05 United Kingdom 0 0 #> 4 2020-01-06 United Kingdom 0 0 #> 5 2020-01-07 United Kingdom 0 0 #> 6 2020-01-08 United Kingdom 0 0"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"onset-to-death-distribution-for-covid-19","dir":"Articles","previous_headings":"Severity of the COVID-19 pandemic in the U.K.","what":"Onset-to-death distribution for Covid-19","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"retrieve appropriate distribution Covid-19 Linton et al. (2020); lognormal distribution μ\\mu = 2.577 σ\\sigma = 0.440. Note Linton et al. (2020) fitted discrete lognormal distribution use continuous distribution, ignoring uncertainty distribution parameters hence likely -estimating uncertainty CFR.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"estimating-the-naive-and-corrected-cfr-1","dir":"Articles","previous_headings":"Severity of the COVID-19 pandemic in the U.K.","what":"Estimating the naive and corrected CFR","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"Finally, calculate naive corrected CFRs Covid-19 pandemic U.K.","code":"# calculating the naive CFR cfr_static( df_covid_uk ) #> severity_estimate severity_low severity_high #> 1 0.03640132 0.03617238 0.0366313 # calculating the corrected CFR cfr_static( df_covid_uk, delay_density = function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440) ) #> severity_estimate severity_low severity_high #> 1 0.0465 0.0462 0.0467"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"details-adjusting-for-delays-between-two-time-series","dir":"Articles","previous_headings":"","what":"Details: Adjusting for delays between two time series","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"cfr_static() follows Nishiura et al. (2009) calculate quantity utu_t day within input data represents proportion cases known adverse outcome (usually death) day tt. ut=∑=0t∑j=0∞ci−jfj∑=0ci, u_t = \\dfrac{\\sum_{= 0}^t \\sum_{j = 0}^\\infty c_{- j} f_{j}}{\\sum_{= 0} c_i}, ftf_t value probability mass function time tt, ctc_t, dtd_t number new cases new deaths time tt (respectively). use utu_t following likelihood function estimate severity. $$ {\\sf L}(\\theta | C_{t},D_{t},u_{t}) = \\log{\\dbinom{u_{t}C_{t}}{D_{t}}} + D_{t} \\log{\\theta} + (u_{t}C_{t} - D_{t})\\log{(1 - \\theta)}, $$ CtC_{t} DtD_{t} cumulative number cases deaths (respectively) time tt. Lastly θ\\theta (severity) estimated θ\\theta using simple maximum-likelihood methods, allowing functions within package quick easy tools use. precise severity measure — CFR, IFR, HFR, etc — θ\\theta represents depends upon input data given user. Case fatality risk (CFR) requires case death incidence data, case--death delay distribution (close approximation, symptom onset--death). Infection fatality risk (IFR) requires infection death incidence data, exposure--death delay distribution (close approximation). Hospitalisation Fatality Risk (HFR) requires hospitalisation death incidence data, appropriate delay distribution (close approximation).","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"use-case","dir":"Articles","previous_headings":"","what":"Use case","title":"Estimating how disease severity varies over the course of an outbreak","text":"substantial changes characteristics outbreak time — introduction therapeutics changing case definition. want estimate disease severity form case fatality risk (CFR) changes time correcting delay reporting outcomes cases.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"what-we-have","dir":"Articles","previous_headings":"","what":"What we have","title":"Estimating how disease severity varies over the course of an outbreak","text":"time-series cases deaths, (cases may substituted another indicator infections time); Data distribution delays, describing probability individual die tt days initially infected.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"potential-reasons-for-changing-disease-severity","dir":"Articles","previous_headings":"","what":"Potential reasons for changing disease severity","title":"Estimating how disease severity varies over the course of an outbreak","text":"Change probability infection reported case, Transmission dynamics within specific subgroups differing risk severe outcomes, Introduction vaccines therapeutics reducing relative risk death, Emergence pathogen variants may alter mortality risk associated infection.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"changing-severity-of-the-covid-19-pandemic-in-the-u-k-","dir":"Articles","previous_headings":"","what":"Changing severity of the Covid-19 pandemic in the U.K.","title":"Estimating how disease severity varies over the course of an outbreak","text":"example shows time-varying severity estimation using cfr data Covid-19 pandemic United Kingdom.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"preparing-the-raw-data","dir":"Articles","previous_headings":"Changing severity of the Covid-19 pandemic in the U.K.","what":"Preparing the raw data","title":"Estimating how disease severity varies over the course of an outbreak","text":"load example Covid-19 daily case death data provided cfr package covid_data, subset first year U.K. data. expect estimated CFR change period due changes pandemic response policy, changes case definitions, implementation relaxation lockdowns, new variants emerging.","code":"# get Covid data loaded with the package data(\"covid_data\") # filter for the U.K df_covid_uk <- filter( covid_data, country == \"United Kingdom\", date <= \"2020-12-31\" ) # View the first few rows and recall necessary columns: date, cases, deaths head(df_covid_uk) #> date country cases deaths #> 1 2020-01-03 United Kingdom 0 0 #> 2 2020-01-04 United Kingdom 0 0 #> 3 2020-01-05 United Kingdom 0 0 #> 4 2020-01-06 United Kingdom 0 0 #> 5 2020-01-07 United Kingdom 0 0 #> 6 2020-01-08 United Kingdom 0 0"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"onset-to-death-distribution-for-covid-19","dir":"Articles","previous_headings":"Changing severity of the Covid-19 pandemic in the U.K.","what":"Onset-to-death distribution for Covid-19","title":"Estimating how disease severity varies over the course of an outbreak","text":"retrieve appropriate distribution duration symptom onset deaths reported Linton et al. (2020); lognormal distribution μ\\mu = 2.577 σ\\sigma = 0.440. Linton et al. (2020) fitted discrete lognormal distribution — use continuous distribution . See vignette delay distributions using continuous instead discrete distribution acceptable, using discrete distributions cfr. Note also use central estimates distribution parameter, ignoring uncertainty parameters uncertainty resulting CFR likely underestimated.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"estimating-the-naive-and-corrected-cfr","dir":"Articles","previous_headings":"Changing severity of the Covid-19 pandemic in the U.K.","what":"Estimating the naive and corrected CFR","title":"Estimating how disease severity varies over the course of an outbreak","text":"use cfr_time_varying() function within cfr package calculate time-varying CFR Covid-19 pandemic U.K., plot results. burn_in time used determine many days start outbreak excluded CFR calculation, potentially due poor data quality beginning outbreak. default value 7, ignores first week data. smoothing_window used smooth case death data using rolling median window corresponding size (days) using stats::runmed() internally — disabled default. Users apply smoothing reporting artefacts lower reporting weekends. Example plot naive time-varying CFR. calculate time-varying CFR Covid-19 pandemic U.K., uncorrected delays. red line shows CFR estimate shaded grey region shows lower upper limits estimate 95% confidence intervals. Note severity estimates confidence intervals cfr_time_varying() obtained Binomial test deaths (treated ‘successes’) estimated outcomes cases (depending whether delay correction applied; treated ‘trials’).","code":"# calculating the naive time-varying CFR df_covid_cfr_uk_naive <- cfr_time_varying( df_covid_uk, burn_in = 7, smoothing_window = 7 ) # calculating the corrected time-varying CFR df_covid_cfr_uk_corrected <- cfr_time_varying( df_covid_uk, delay_density = function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440), burn_in = 7, smoothing_window = 7 ) # assign method tag and plot df_covid_cfr_uk_naive$method <- \"naive\" df_covid_cfr_uk_corrected$method <- \"corrected\" df_covid_cfr_uk <- bind_rows(df_covid_cfr_uk_naive, df_covid_cfr_uk_corrected) ggplot(df_covid_cfr_uk) + geom_ribbon( aes( x = date, ymin = severity_low, ymax = severity_high, fill = method ), alpha = 0.5 ) + geom_line( aes( x = date, y = severity_estimate, colour = method ) ) + scale_x_date( date_labels = \"%b-%Y\" ) + scale_y_continuous( labels = percent ) + scale_fill_brewer( palette = \"Dark2\", name = NULL, labels = c(\"Naive CFR\", \"Corrected CFR\") ) + scale_colour_brewer( palette = \"Dark2\", name = NULL, labels = c(\"Naive CFR\", \"Corrected CFR\") ) + labs( x = \"Date\", y = \"CFR (%)\" ) + coord_cartesian( expand = FALSE ) + theme_classic() + theme(legend.position = \"top\") #> Warning: Removed 93 rows containing missing values or values outside the scale range #> (`geom_line()`)."},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"severity-of-covid-19-in-multiple-countries","dir":"Articles","previous_headings":"","what":"Severity of Covid-19 in multiple countries","title":"Estimating how disease severity varies over the course of an outbreak","text":"cfr_time_varying() cfr functions can conveniently applied nested data estimate time-varying severity Covid-19. refer user book R Data Science better explanation code used , including packages Tidyverse. use example Covid-19 cases deaths data provided package covid_data, excluding four countries provide weekly data (zeros dates ). simplicity, use delay distribution onset death countries — users note likely introduces biases given inter-country differences testing reporting policies. Finally plot time-varying CFR selection three countries large outbreaks Covid-19: Brazil, India, United States. Example plot corrected time-varying CFR. calculate time-varying CFR Covid-19 pandemic Brazil, India, United States, corrected delays.","code":"# countries with weekly reporting weekly_reporting <- c(\"France\", \"Germany\", \"Spain\", \"Ukraine\") covid_data <- filter(covid_data, !country %in% weekly_reporting) # for each country, get the time-varying severity estimate, # correcting for delays and smoothing the case and death data # first nest the data; nest() from {tidyr} df_covid_cfr <- nest( covid_data, .by = country ) # define delay density function delay_density <- function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440) # to each nested data frame, apply the function `cfr_time_varying` # overwrite the `data` column, as all data will be preserved df_covid_cfr <- mutate( df_covid_cfr, # using map() from {purrr} data = map( .x = data, .f = cfr_time_varying, # arguments to the function delay_density = delay_density, smoothing_window = 7, burn_in = 7 ) ) # unnest the cfr data; unnest() from {tidyr} df_covid_cfr <- unnest(df_covid_cfr, cols = data) filter(df_covid_cfr, country %in% c(\"Brazil\", \"India\", \"United States\")) %>% ggplot() + geom_ribbon( aes( x = date, ymin = severity_low, ymax = severity_high, group = country ), fill = \"grey\" ) + geom_line( aes( x = date, y = severity_estimate, colour = country ) ) + scale_x_date( date_labels = \"%b-%Y\" ) + scale_y_continuous( labels = percent ) + scale_colour_brewer( palette = \"Dark2\" ) + labs( x = \"Date\", y = \"CFR (%)\" ) + coord_cartesian( ylim = c(0, 0.15), expand = FALSE ) + theme_classic() + theme(legend.position = \"top\") #> Warning: Removed 215 rows containing missing values or values outside the scale range #> (`geom_line()`)."},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"details-adjusting-for-delays-between-two-time-series","dir":"Articles","previous_headings":"","what":"Details: Adjusting for delays between two time series","title":"Estimating how disease severity varies over the course of an outbreak","text":"cfr_time_varying() estimates number cases known outcome time following Nishiura et al. (2009), calculating quantity ktk_t day within input data, represents number cases known adverse outcome (usually death), day tt. kt=∑j=0tctfj−t. k_t = \\sum_{j = 0}^t c_t f_{j - t}. assume severity measure (usually CFR) binomially distributed following way $$ d_t \\sim {\\sf Binomial}(k_t, \\theta_t). $$ use maximum likelihood estimation determine value θt\\theta_t tt, θ\\theta represents severity measure interest. precise severity measure — case fatality risk (CFR), infection fatality risk (IFR), hospitalisation fatality risk (HFR), etc. — θ\\theta represents depends upon input data given user. Note function arguments burn_in smoothing_window explicitly used calculation. burn_in controls many estimates beginning outbreak replaced NAs — calculation applied first burn_in data points. calculation applied smoothed data, smoothing_window specified.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/articles/software-permissions.html","id":"scope-of-regulations","dir":"Articles","previous_headings":"","what":"Scope of regulations","title":"Software permissions and regulations","text":"package Software Medical Device (SaMD).","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/software-permissions.html","id":"data-privacy-and-integrity","dir":"Articles","previous_headings":"","what":"Data privacy and integrity","title":"Software permissions and regulations","text":"package read data user computer package write data user computer package interact external peripherals connected user computer (, limited : microphone, webcam, printer, etc.)","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/software-permissions.html","id":"internet-access","dir":"Articles","previous_headings":"","what":"Internet access","title":"Software permissions and regulations","text":"package download data internet package upload data internet package CAN used offline","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/software-permissions.html","id":"registration-and-third-parties","dir":"Articles","previous_headings":"","what":"Registration and third parties","title":"Software permissions and regulations","text":"Usage package require registration Usage package involve third-party services Usage package restricted certain geographical regions","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/software-permissions.html","id":"updates","dir":"Articles","previous_headings":"","what":"Updates","title":"Software permissions and regulations","text":"package automatically updated. Note means security updates automatically applied.","code":""},{"path":"https://epiverse-trace.github.io/cfr/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Pratik R. Gupte. Author, copyright holder. Adam Kucharski. Author, copyright holder, maintainer. Tim Russell. Author, copyright holder. Joshua W. Lambert. Reviewer. Hugo Gruson. Reviewer. Tim Taylor. Reviewer. James M. Azam. Reviewer. Abdoelnaser M. Degoot. Reviewer. Sebastian Funk. Reviewer.","code":""},{"path":"https://epiverse-trace.github.io/cfr/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Gupte P, Kucharski , Russell T (2024). cfr: Estimate Disease Severity Case Ascertainment. R package version 0.1.3, https://epiverse-trace.github.io/cfr/, https://github.com/epiverse-trace/cfr.","code":"@Manual{, title = {cfr: Estimate Disease Severity and Case Ascertainment}, author = {Pratik R. Gupte and Adam Kucharski and Tim Russell}, year = {2024}, note = {R package version 0.1.3, https://epiverse-trace.github.io/cfr/}, url = {https://github.com/epiverse-trace/cfr}, }"},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"cfr-estimate-disease-severity-and-under-reporting-","dir":"","previous_headings":"","what":"Estimate Disease Severity and Case Ascertainment","title":"Estimate Disease Severity and Case Ascertainment","text":"cfr R package estimate disease severity -reporting real-time, accounting delays epidemic time-series. cfr provides simple, fast methods calculate overall static case fatality risk (CFR) outbreak given time point, well CFR changes course outbreak. cfr can help estimate disease -reporting real-time, accounting delays reporting outcomes cases. cfr implements methods outlined Nishiura et al. (2009). plans add estimates based methods. cfr developed Centre Mathematical Modelling Infectious Diseases London School Hygiene Tropical Medicine part Epiverse-TRACE initiative.","code":""},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Estimate Disease Severity and Case Ascertainment","text":"cfr can installed CRAN using current development version cfr can installed GitHub using pak package.","code":"install.packages(\"cfr\") if(!require(\"pak\")) install.packages(\"pak\") pak::pak(\"epiverse-trace/cfr\")"},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"overall-severity-of-the-1976-ebola-outbreak","dir":"","previous_headings":"Quick start","what":"Overall severity of the 1976 Ebola outbreak","title":"Estimate Disease Severity and Case Ascertainment","text":"example shows use cfr estimate overall case fatality risks 1976 Ebola outbreak (Camacho et al. 2014), correcting delays using Gamma-distributed onset death duration taken Barry et al. (2018), shape kk 2.40 scale θ\\theta 3.33.","code":"# Load package library(cfr) # Load the Ebola 1976 data provided with the package data(ebola1976) # Focus on the first 20 days the outbreak ebola1976_first_30 <- ebola1976[1:30, ] # Calculate the static CFR without correcting for delays cfr_static(data = ebola1976_first_30) #> severity_estimate severity_low severity_high #> 1 0.4740741 0.3875497 0.5617606 # Calculate the static CFR while correcting for delays cfr_static( data = ebola1976_first_30, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) #> severity_estimate severity_low severity_high #> 1 0.9422 0.8701 0.9819"},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"change-in-real-time-estimates-of-overall-severity-during-the-1976-ebola-outbreak","dir":"","previous_headings":"Quick start","what":"Change in real-time estimates of overall severity during the 1976 Ebola outbreak","title":"Estimate Disease Severity and Case Ascertainment","text":"example show estimate overall severity can change data cases deaths time becomes available, using function cfr_rolling(). delay onset--death, simple “naive” calculation just divides deaths--date cases--date underestimate severity. cfr_rolling() function uses estimate_severity() adjustment internally account delays, instead compares deaths--date cases--known-outcome--date. adjusted estimate converges naive estimate outbreak declines larger proportion cases known outcomes. plot rolling CFR visualise severity changes time, using ggplot2 package. plotting code hidden . Disease severity ebola 1976 outbreak estimated day epidemic. rolling CFR value converges static value towards end outbreak. corrected uncorrected estimates shown.","code":"# Calculate the CFR without correcting for delays on each day of the outbreak rolling_cfr_naive <- cfr_rolling( data = ebola1976 ) # see the first few rows head(rolling_cfr_naive) #> date severity_estimate severity_low severity_high #> 1 1976-08-25 0 0 0.975 #> 2 1976-08-26 0 0 0.975 #> 3 1976-08-27 0 0 0.975 #> 4 1976-08-28 0 0 0.975 #> 5 1976-08-29 0 0 0.975 #> 6 1976-08-30 0 0 0.975 # Calculate the rolling daily CFR while correcting for delays rolling_cfr_corrected <- cfr_rolling( data = ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) head(rolling_cfr_corrected) #> date severity_estimate severity_low severity_high #> 1 1976-08-25 NA NA NA #> 2 1976-08-26 1e-04 1e-04 0.9999 #> 3 1976-08-27 1e-04 1e-04 0.9999 #> 4 1976-08-28 1e-04 1e-04 0.9999 #> 5 1976-08-29 1e-04 1e-04 0.9990 #> 6 1976-08-30 1e-04 1e-04 0.9942 # combine the data for plotting rolling_cfr_naive$method <- \"naive\" rolling_cfr_corrected$method <- \"corrected\" data_cfr <- rbind( rolling_cfr_naive, rolling_cfr_corrected )"},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"package-vignettes","dir":"","previous_headings":"","what":"Package vignettes","title":"Estimate Disease Severity and Case Ascertainment","text":"details use cfr can found online documentation package vignettes, “Articles”.","code":""},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"help","dir":"","previous_headings":"","what":"Help","title":"Estimate Disease Severity and Case Ascertainment","text":"report bug please open issue.","code":""},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"contribute","dir":"","previous_headings":"","what":"Contribute","title":"Estimate Disease Severity and Case Ascertainment","text":"Contributions cfr welcomed. Please follow package contributing guide.","code":""},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of conduct","title":"Estimate Disease Severity and Case Ascertainment","text":"Please note cfr project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"related-projects","dir":"","previous_headings":"","what":"Related projects","title":"Estimate Disease Severity and Case Ascertainment","text":"cfr functionality overlaps packages, including coarseDataTools R package allows estimation relative case fatality risk covariate groups accounting delays due survival time, numbers deaths recoveries time known. cfr uses simpler methods Nishiura et al. (2009) can applied cases deaths time known, generating estimates based data date, well time-varying estimates. cfr can also convert estimates cases known outcomes time estimate -ascertainment, baseline estimate fatality risk available literature (e.g. past outbreaks). EpiNow2 R package can allow estimation case fatality risk defined secondary observation cases. particular, allows estimation accounts smooth underlying epidemic process, requires additional computational effort. comparison methods planned future release. cfr future expected benefit functionality forthcoming epiparameter package, also developed Epiverse-TRACE. epiparameter aims provide library epidemiological parameters parameterise delay density functions, well convenient class store, access, pass parameters delay correction.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr-package.html","id":null,"dir":"Reference","previous_headings":"","what":"cfr: Estimate Disease Severity and Case Ascertainment — cfr-package","title":"cfr: Estimate Disease Severity and Case Ascertainment — cfr-package","text":"Estimate severity disease ascertainment cases, discussed Nishiura et al. (2009) doi:10.1371/journal.pone.0006852 .","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"cfr: Estimate Disease Severity and Case Ascertainment — cfr-package","text":"Maintainer: Adam Kucharski adam.kucharski@lshtm.ac.uk (ORCID) [copyright holder] Authors: Pratik R. Gupte pratik.gupte@lshtm.ac.uk (ORCID) [copyright holder] Tim Russell timothy.russell@lshtm.ac.uk (ORCID) [copyright holder] contributors: Joshua W. Lambert joshua.lambert@lshtm.ac.uk (ORCID) [reviewer] Hugo Gruson hugo.gruson@data.org (ORCID) [reviewer] Tim Taylor tim.taylor@hiddenelephants.co.uk (ORCID) [reviewer] James M. Azam james.azam@lshtm.ac.uk (ORCID) [reviewer] Abdoelnaser M. Degoot abdoelnaser-mahmood.degoot@lshtm.ac.uk (ORCID) [reviewer] Sebastian Funk sebastian.funk@lshtm.ac.uk (ORCID) [reviewer]","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_rolling.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate static severity for an expanding time series — cfr_rolling","title":"Estimate static severity for an expanding time series — cfr_rolling","text":"Calculates CFR time point case death time series supplied, using expanding window time. static CFR calculated time point, using time series start time point, increasing number time points included one iteration.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_rolling.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate static severity for an expanding time series — cfr_rolling","text":"","code":"cfr_rolling(data, delay_density = NULL, poisson_threshold = 100)"},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_rolling.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate static severity for an expanding time series — cfr_rolling","text":"data containing outbreak data. daily time series dates absolute indicator time (e.g. epiday epiweek) numbers new cases new deaths time point. Note required columns \"date\" (date), \"cases\" (number reported cases), \"deaths\" (number reported deaths) day outbreak. Note required unbroken sequence dates missing dates . \"date\" column must class Date (see .Date()). Note also total number cases must greater total number reported deaths. delay_density optional argument controls whether delay correction applied severity estimation. May NULL, delay correction, function returns density function distribution evaluate density user-specified values, e.g. function(x) stats::dgamma(x = x, shape = 5, scale = 1). poisson_threshold case count use Poisson approximation. Set 100 default. Must > 0.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_rolling.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate static severity for an expanding time series — cfr_rolling","text":" date, maximum likelihood estimate 95% confidence interval daily severity estimates, named \"severity_estimate\", \"severity_low\", \"severity_high\", one row day original data.frame.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_rolling.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Estimate static severity for an expanding time series — cfr_rolling","text":"delay correction applied passing delay distribution density function delay_density, internal function .estimate_severity() used calculate rolling severity. Note naive method severity estimate confidence intervals calculated days cumulative number cases since start time-series, days cumulative number deaths reported exceeds cumulative reported cases, returned NA. cfr_rolling() applies internal function .estimate_severity() expanding time-series total cases, total estimated outcomes, total deaths. method used generate profile likelihood day depends outbreak size initial severity estimate day. essentially running cfr_static() new day. method used day communicated user, order prevent cluttering terminal messages.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_rolling.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate static severity for an expanding time series — cfr_rolling","text":"","code":"# load package data data(\"ebola1976\") # estimate severity without correcting for delays cfr_static(ebola1976) #> severity_estimate severity_low severity_high #> 1 0.955102 0.9210866 0.9773771 # estimate severity for each day while correcting for delays # obtain onset-to-death delay distribution parameters from Barry et al. 2018 # The Lancet. # view only the first values estimate <- cfr_rolling( ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) #> `cfr_rolling()` is a convenience function to help understand how additional data influences the overall (static) severity. Use `cfr_time_varying()` instead to estimate severity changes over the course of the outbreak. #> Some daily ratios of total deaths to total cases with known outcome are below 0.01%: some CFR estimates may be unreliable.FALSE head(estimate) #> date severity_estimate severity_low severity_high #> 1 1976-08-25 NA NA NA #> 2 1976-08-26 1e-04 1e-04 0.9999 #> 3 1976-08-27 1e-04 1e-04 0.9999 #> 4 1976-08-28 1e-04 1e-04 0.9999 #> 5 1976-08-29 1e-04 1e-04 0.9990 #> 6 1976-08-30 1e-04 1e-04 0.9942"},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate a static disease severity measure — cfr_static","title":"Estimate a static disease severity measure — cfr_static","text":"Calculates severity disease, optionally correcting reporting delays using epidemiological delay distribution time symptom onset death (onset--death). delay distributions may passed calculate different disease severity measures hospitalisation fatality risk.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate a static disease severity measure — cfr_static","text":"","code":"cfr_static(data, delay_density = NULL, poisson_threshold = 100)"},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate a static disease severity measure — cfr_static","text":"data containing outbreak data. daily time series dates absolute indicator time (e.g. epiday epiweek) numbers new cases new deaths time point. Note required columns \"date\" (date), \"cases\" (number reported cases), \"deaths\" (number reported deaths) day outbreak. Note required unbroken sequence dates missing dates . \"date\" column must class Date (see .Date()). Note also total number cases must greater total number reported deaths. delay_density optional argument controls whether delay correction applied severity estimation. May NULL, delay correction, function returns density function distribution evaluate density user-specified values, e.g. function(x) stats::dgamma(x = x, shape = 5, scale = 1). poisson_threshold case count use Poisson approximation. Set 100 default. Must > 0.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate a static disease severity measure — cfr_static","text":" maximum likelihood estimate 95% confidence interval severity estimates, named \"severity_estimate\", \"severity_low\", \"severity_high\".","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"details-adjusting-for-delays-between-two-time-series","dir":"Reference","previous_headings":"","what":"Details: Adjusting for delays between two time series","title":"Estimate a static disease severity measure — cfr_static","text":"method used cfr_static() follows Nishiura et al. (2009). function calculates quantity \\(u_t\\) day within input data, represents proportion cases estimated known outcome day \\(t\\). Following Nishiura et al., \\(u_t\\) calculated : $$u_t = \\dfrac{\\sum_{= 0}^t \\sum_{j = 0}^\\infty c_i f_{j - }}{\\sum_{= 0} c_i}$$ \\(f_t\\) value probability mass function time \\(t\\) \\(c_t\\), \\(d_t\\) number new cases new deaths time \\(t\\), (respectively). use \\(u_t\\) end outbreak following likelihood function estimate severity disease question. $${\\sf L}({\\theta \\mid y}) = \\log{\\dbinom{u_tC}{D}} + D \\log{\\theta} + (u_tC - D)\\log{(1.0 - \\theta)}$$ \\(C\\) \\(D\\) cumulative number cases deaths (respectively) time \\(t\\). \\(\\theta\\) parameter wish estimate, severity disease. estimate \\(\\theta\\) using simple maximum-likelihood methods, allowing functions within package quick easy tools use. precise severity measure — CFR, IFR, HFR, etc — \\(\\theta\\) represents depends upon input data given user. epidemiological delay-distribution density function passed delay_density used evaluate probability mass function parameterised time; .e. \\(f(t)\\) gives probability case known outcome (usually death) time \\(t\\), parameterised disease-specific parameters supplied .","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"profile-likelihood-methods","dir":"Reference","previous_headings":"","what":"Profile likelihood methods","title":"Estimate a static disease severity measure — cfr_static","text":"naive CFR estimate (without delay correction) outcome Binomial test deaths cases using stats::binom.test(). confidence intervals around estimate also taken test. delay-corrected CFR estimates however obtained generating profile likelihood sequence seq(1e-4, 1.0, 1e-4). method used depends outbreak size initial expectation disease severity. implemented internal function .estimate_severity(). Delay correction, small outbreaks: outbreaks total cases user-specified 'Poisson threshold' (poisson_threshold, default = 100), CFR uncertainty around taken profile likelihood generated Binomial model deaths (successes) estimated known outcomes (trials). Delay correction, large outbreaks low severity: outbreaks total cases greater Poisson threshold (default = 100) initial severity estimates < 0.05, CFR uncertainty taken Poisson approximation Binomial profile likelihood (taking \\(\\lambda = np\\) \\(n\\) estimated outcomes \\(p\\) severity estimate). Delay correction, large outbreaks higher severity: outbreaks total cases greater Poisson threshold (default = 100) initial severity estimates \\(\\geq\\) 0.05, CFR uncertainty taken Normal approximation Binomial profile likelihood.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Estimate a static disease severity measure — cfr_static","text":"Nishiura, H., Klinkenberg, D., Roberts, M., & Heesterbeek, J. . P. (2009). Early Epidemiological Assessment Virulence Emerging Infectious Diseases: Case Study Influenza Pandemic. PLOS ONE, 4(8), e6852. doi:10.1371/journal.pone.0006852","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate a static disease severity measure — cfr_static","text":"","code":"# load package data data(\"ebola1976\") # estimate severity without correcting for delays cfr_static(ebola1976) #> severity_estimate severity_low severity_high #> 1 0.955102 0.9210866 0.9773771 # estimate severity for each day while correcting for delays # obtain onset-to-death delay distribution parameters from Barry et al. 2018 # The Lancet. cfr_static( ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) #> severity_estimate severity_low severity_high #> 1 0.9592 0.9295 0.9793"},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate a severity measure that varies over time — cfr_time_varying","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":"Calculates severity disease changes time optionally correcting reporting delays using epidemiological delay distribution time symptom onset outcome (e.g. onset--death fatality risk).","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":"","code":"cfr_time_varying( data, delay_density = NULL, burn_in = 7, smoothing_window = NULL )"},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":"data containing outbreak data. daily time series dates absolute indicator time (e.g. epiday epiweek) numbers new cases new deaths time point. Note required columns \"date\" (date), \"cases\" (number reported cases), \"deaths\" (number reported deaths) day outbreak. Note required unbroken sequence dates missing dates . \"date\" column must class Date (see .Date()). Note also total number cases must greater total number reported deaths. delay_density optional argument controls whether delay correction applied severity estimation. May NULL, delay correction, function returns density function distribution evaluate density user-specified values, e.g. function(x) stats::dgamma(x = x, shape = 5, scale = 1). burn_in single integer-like value number time-points (typically days) disregard start time-series, burn-period desired. Defaults 7, sensible default value disregards first week cases deaths, assuming daily data. consider case data including start time-series, set argument 0. smoothing_window odd number determining smoothing window size use smoothing case death time-series, using rolling median procedure (k argument stats::runmed()) calculating time-varying severity. default behaviour apply smoothing. minimum value argument 1.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":" date, maximum likelihood estimate 95% confidence interval daily severity estimates, named \"severity_estimate\", \"severity_low\", \"severity_high\", one row day original data.frame.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":"details-adjusting-for-delays-between-two-time-series","dir":"Reference","previous_headings":"","what":"Details: Adjusting for delays between two time series","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":"function estimates number cases known outcome time, following Nishiura et al. (2009). function calculates quantity \\(k_t\\) day within input data, represents number cases estimated known outcome, day \\(t\\). \\(k_t\\) calculated following way: $$k_t = \\sum_{j = 0}^t c_t f_{j - t}$$ assume severity measure, example CFR, interest binomially distributed, following way: $$d_t \\sim {\\sf Binomial}(k_t, \\theta_t)$$ use maximum likelihood estimation determine value \\(\\theta_t\\) \\(t\\), \\(\\theta\\) represents severity measure interest. epidemiological delay distribution passed delay_density used obtain probability mass function parameterised time; .e. \\(f(t)\\) gives probability binary outcome case (survival death) known time \\(t\\). delay distribution parameterised disease-specific parameters supplied . Note function arguments burn_in smoothing_window explicitly used calculation. burn_in controls many estimates beginning outbreak replaced NAs — calculation applied first burn_in data points. calculation applied smoothed data, smoothing_window specified.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":"Nishiura, H., Klinkenberg, D., Roberts, M., & Heesterbeek, J. . P. (2009). Early Epidemiological Assessment Virulence Emerging Infectious Diseases: Case Study Influenza Pandemic. PLOS ONE, 4(8), e6852. doi:10.1371/journal.pone.0006852","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":"","code":"# get data pre-loaded with the package data(\"covid_data\") df_covid_uk <- covid_data[covid_data$country == \"United Kingdom\" & covid_data$date <= as.Date(\"2020-09-01\"), ] # estimate time varying severity without correcting for delays cfr_time_varying <- cfr_time_varying( data = df_covid_uk, burn_in = 7L ) # View tail(cfr_time_varying) #> date severity_estimate severity_low severity_high #> 238 2020-08-27 0.017322835 0.010887155 0.02611008 #> 239 2020-08-28 0.011527378 0.006602850 0.01865240 #> 240 2020-08-29 0.007542426 0.003903177 0.01313800 #> 241 2020-08-30 0.007352941 0.003804975 0.01280885 #> 242 2020-08-31 0.006504065 0.002812052 0.01277518 #> 243 2020-09-01 0.009393681 0.004698353 0.01674560 # estimate time varying severity while correcting for delays # obtain onset-to-death delay distribution parameters from Linton et al. 2020 # J. Clinical Medicine: # view only the first values cfr_time_varying <- cfr_time_varying( data = df_covid_uk, delay_density = function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440), burn_in = 7L ) tail(cfr_time_varying) #> date severity_estimate severity_low severity_high #> 238 2020-08-27 0.021317829 0.013406829 0.03209837 #> 239 2020-08-28 0.015281757 0.008759411 0.02469826 #> 240 2020-08-29 0.011310085 0.005857363 0.01967302 #> 241 2020-08-30 0.011204482 0.005802549 0.01949011 #> 242 2020-08-31 0.007407407 0.003203259 0.01454312 #> 243 2020-09-01 0.010110294 0.005057522 0.01801795"},{"path":"https://epiverse-trace.github.io/cfr/reference/covid_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Daily Covid-19 case and death data for countries with 100,000 or more deaths — covid_data","title":"Daily Covid-19 case and death data for countries with 100,000 or more deaths — covid_data","text":"Data adapted {covidregionaldata} package daily cases deaths 19 countries 100,000 deaths period 2020-01-01 2022-12-31. See References publication links data sources made available {covidregionaldata}. Included {covidregionaldata} longer CRAN. Data provided .","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/covid_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Daily Covid-19 case and death data for countries with 100,000 or more deaths — covid_data","text":"","code":"covid_data"},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/reference/covid_data.html","id":"covid-data","dir":"Reference","previous_headings":"","what":"covid_data","title":"Daily Covid-19 case and death data for countries with 100,000 or more deaths — covid_data","text":" 20,786 rows 4 columns: date Calendar date format %Y-%m-%d country country name simple format, e.g. \"United States\" rather \"United States America\" cases Number cases reported date deaths Number deaths reported date","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/covid_data.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Daily Covid-19 case and death data for countries with 100,000 or more deaths — covid_data","text":"doi:10.21105/joss.03290 .","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/covid_data.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Daily Covid-19 case and death data for countries with 100,000 or more deaths — covid_data","text":"Joseph Palmer, Katharine Sherratt, Richard Martin-Nielsen, Jonnie Bevan, Hamish Gibbs, Sebastian Funk Sam Abbott (2021). covidregionaldata: Subnational data COVID-19 epidemiology. doi:10.21105/joss.03290","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/delay_density_helpers.html","id":null,"dir":"Reference","previous_headings":"","what":"Check delay density functions passed to exported functions — delay_density_helpers","title":"Check delay density functions passed to exported functions — delay_density_helpers","text":"Internal helper function check whether function passed delay_density argument cfr_*() estimate_outcomes() meet requirements package methods. test_fn_req_args() checks whether function expected number required arguments, .e., arguments without default values. Defaults checking single required argument. test_fn_num_out() checks whether function returns numeric output consistent evaluating probability density probability mass function distribution sequence values. Expects function returns numeric vector finite values \\(\\geq\\) 0.0, values missing, output vector length input vector.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/delay_density_helpers.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check delay density functions passed to exported functions — delay_density_helpers","text":"","code":"test_fn_req_args(fn, n_req_args = 1) test_fn_num_out(fn, n = 10)"},{"path":"https://epiverse-trace.github.io/cfr/reference/delay_density_helpers.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check delay density functions passed to exported functions — delay_density_helpers","text":"fn function. expected function evaluating density distribution numeric values, suitable passed delay_density cfr_*(). n_req_args number required arguments, .e., arguments without default values. n number elements evaluate function fn. Defaults 10, fn evaluated seq(n).","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/delay_density_helpers.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check delay density functions passed to exported functions — delay_density_helpers","text":"logical whether function fn fulfils conditions specified respective checks.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-estimate_severity.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate the corrected case fatality risk — .estimate_severity","title":"Estimate the corrected case fatality risk — .estimate_severity","text":"Estimates maximum likelihood estimate 95% confidence interval corrected severity, using total cases total cases known outcomes, latter replaces total number deaths standard (naive) severity definition. use binomial likelihood, approximated Poisson likelihood large samples.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-estimate_severity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate the corrected case fatality risk — .estimate_severity","text":"","code":".estimate_severity( total_cases, total_deaths, total_outcomes, poisson_threshold, p_mid = total_deaths/round(total_outcomes) )"},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-estimate_severity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate the corrected case fatality risk — .estimate_severity","text":"total_cases total number cases observed period outbreak interest. total number cases must greater equal total number deaths. total_deaths total number deaths observed period outbreak interest. total number deaths must less equal total number cases. total_outcomes total number outcomes expected observed period outbreak interest. See estimate_outcomes(). poisson_threshold case count use Poisson approximation. Set 100 default. Must > 0. p_mid initial severity estimate, used determine likelihood approximation used total_cases > poisson_threshold. Defaults total_deaths / round(total_outcomes).","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-estimate_severity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate the corrected case fatality risk — .estimate_severity","text":" one row three columns maximum likelihood estimate 95% confidence interval corrected severity estimates, named \"severity_estimate\", \"severity_low\", \"severity_high\".","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-estimate_severity.html","id":"special-cases","dir":"Reference","previous_headings":"","what":"Special cases","title":"Estimate the corrected case fatality risk — .estimate_severity","text":"two total_cases, total_deaths, total_outcomes 0, estimate confidence intervals calculated output contains NAs. total_outcomes <= total_deaths, estimate confidence intervals reliably calculated returned NA.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-select_func_likelihood.html","id":null,"dir":"Reference","previous_headings":"","what":"Select a likelihood function for severity estimation — .select_func_likelihood","title":"Select a likelihood function for severity estimation — .select_func_likelihood","text":"Switches Binomial, Poisson, Normal approximation based total number cases initial estimate severity.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-select_func_likelihood.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select a likelihood function for severity estimation — .select_func_likelihood","text":"","code":".select_func_likelihood(total_cases, poisson_threshold, p_mid)"},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-select_func_likelihood.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select a likelihood function for severity estimation — .select_func_likelihood","text":"total_cases single count total number cases outbreak. poisson_threshold single count threshold cases Poisson Normal approximation returned. p_mid single positive number bounded 0 – 1, representing initial estimate severity, used determine whether Poisson Normal approximation returned. determine whether","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-select_func_likelihood.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select a likelihood function for severity estimation — .select_func_likelihood","text":"function three arguments, total_outcomes, total_deaths, pp, used generate profile likelihood. Also prints messages screen Poisson Normal approximation function returned.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-select_func_likelihood.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Select a likelihood function for severity estimation — .select_func_likelihood","text":"Returns likelihood function follows: Binomial approximation: total_cases < poisson_threshold, used cases, small outbreak; Poisson approximation: total_cases >= poisson_threshold p_mid < 0.05;","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/ebola1976.html","id":null,"dir":"Reference","previous_headings":"","what":"Ebola 1976 outbreak case data — ebola1976","title":"Ebola 1976 outbreak case data — ebola1976","text":"example epidemic outbreak dataset use cfr package. dataset comes first Ebola outbreak Zaire 1976 analysed Camacho et al. (2014).","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/ebola1976.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ebola 1976 outbreak case data — ebola1976","text":"","code":"ebola1976"},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/reference/ebola1976.html","id":"ebola-","dir":"Reference","previous_headings":"","what":"ebola1976","title":"Ebola 1976 outbreak case data — ebola1976","text":" 73 rows 3 columns: date Calendar date cases Number cases reported deaths Number deaths reported","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/ebola1976.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Ebola 1976 outbreak case data — ebola1976","text":"doi:10.1016/j.epidem.2014.09.003","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/ebola1976.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Ebola 1976 outbreak case data — ebola1976","text":"Camacho, ., Kucharski, . J., Funk, S., Breman, J., Piot, P., & Edmunds, W. J. (2014). Potential large outbreaks Ebola virus disease. Epidemics, 9, 70–78. doi:10.1016/j.epidem.2014.09.003","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_ascertainment.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","title":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","text":"Estimates proportion cases infections ascertained, given time-series cases deaths, delay distribution baseline severity estimate. resulting ascertainment estimate calculated ratio baseline severity estimate, assumed 'true' disease severity, delay-adjusted severity estimate.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_ascertainment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","text":"","code":"estimate_ascertainment(data, severity_baseline, delay_density = NULL)"},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_ascertainment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","text":"data containing outbreak data. daily time series dates absolute indicator time (e.g. epiday epiweek) numbers new cases new deaths time point. Note required columns \"date\" (date), \"cases\" (number reported cases), \"deaths\" (number reported deaths) day outbreak. Note required unbroken sequence dates missing dates . \"date\" column must class Date (see .Date()). Note also total number cases must greater total number reported deaths. severity_baseline single number range 0.0 – 1.0 assumed true baseline severity estimate used estimate overall ascertainment ratio. Missing default, causes function error; must supplied user. delay_density optional argument controls whether delay correction applied severity estimation. May NULL, delay correction, function returns density function distribution evaluate density user-specified values, e.g. function(x) stats::dgamma(x = x, shape = 5, scale = 1).","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_ascertainment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","text":" containing maximum likelihood estimate estimate 95% confidence interval corrected severity, named \"ascertainment_estimate\" (central estimate), \"ascertainment_low\" \"ascertainment_high\" lower upper interval limits.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_ascertainment.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","text":"estimate_ascertainment() uses cfr_static() internally obtain severity estimate compared user-specified baseline severity. profile likelihood method used obtain severity estimate decided internal function .estimate_severity() used cfr_static(), delay correction applied. See cfr_static() documentation explanation methods used depending outbreak size initial severity guess.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_ascertainment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","text":"","code":"# get data pre-loaded with the package data(\"covid_data\") df_covid_uk <- covid_data[covid_data$country == \"United Kingdom\", ] df_covid_uk_subset <- subset(df_covid_uk, date <= \"2020-05-31\") # use a severity baseline of 1.4% (0.014) taken from Verity et al. (2020) # Lancet Infectious Diseases: # use onset-to-death distribution from Linton et al. (2020) # J. Clinical Medicine: # subset data until 30th June 2020 data <- df_covid_uk[df_covid_uk$date <= \"2020-06-30\", ] estimate_ascertainment( data = data, delay_density = function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440), severity_baseline = 0.014 ) #> ascertainment_estimate ascertainment_low ascertainment_high #> 1 0.06779661 0.06734007 0.06829268"},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_outcomes.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","title":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","text":"Estimates expected number individuals known outcomes case outcome time series outbreak data, epidemiological delay distribution symptom onset outcome. calculating case fatality risk, outcomes must deaths, delay distribution must onset--death distribution, function returns estimates known death outcomes.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_outcomes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","text":"","code":"estimate_outcomes(data, delay_density)"},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_outcomes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","text":"data containing outbreak data. daily time series dates absolute indicator time (e.g. epiday epiweek) numbers new cases new deaths time point. Note required columns \"date\" (date), \"cases\" (number reported cases), \"deaths\" (number reported deaths) day outbreak. Note required unbroken sequence dates missing dates . \"date\" column must class Date (see .Date()). Note also total number cases must greater total number reported deaths. delay_density optional argument controls whether delay correction applied severity estimation. May NULL, delay correction, function returns density function distribution evaluate density user-specified values, e.g. function(x) stats::dgamma(x = x, shape = 5, scale = 1).","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_outcomes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","text":" columns data, two additional columns: \"estimated_outcomes\" number cases outcome interest (usually, death) estimated known dates specified data, u_t ratio cumulative number estimated known outcomes cumulative number cases reported date specified data.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_outcomes.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","text":"ratio u_t represents, outbreak, overall proportion cases whose outcomes expected known day $$. ongoing outbreak relatively long delays symptom onset case outcome, u_t value 1.0 may indicate outbreak ended, outcomes cases expected known.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_outcomes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","text":"","code":"# Load Ebola 1976 outbreak data data(\"ebola1976\") # estimate severity for each day while correcting for delays # obtain onset-to-death delay distribution parameters from Barry et al. 2018 # examine the first few rows of the output estimated_outcomes <- estimate_outcomes( data = ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) head(estimated_outcomes) #> date cases deaths estimated_outcomes u_t #> 1 1976-08-25 1 0 0.00000000 0.00000000 #> 2 1976-08-26 0 0 0.03323030 0.03323030 #> 3 1976-08-27 0 0 0.06494676 0.09817706 #> 4 1976-08-28 0 0 0.08485286 0.18302992 #> 5 1976-08-29 0 0 0.09400738 0.27703731 #> 6 1976-08-30 0 0 0.09515185 0.37218916"},{"path":"https://epiverse-trace.github.io/cfr/reference/prepare_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare common epidemiological data formats for CFR estimation — prepare_data","title":"Prepare common epidemiological data formats for CFR estimation — prepare_data","text":"S3 generic methods classes commonly used epidemiological data. Currently, supported data format incidence2 package. See incidence2::incidence(). Grouped data supported, see Details.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/prepare_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare common epidemiological data formats for CFR estimation — prepare_data","text":"","code":"prepare_data(data, ...) # S3 method for class 'incidence2' prepare_data( data, cases_variable = \"cases\", deaths_variable = \"deaths\", fill_NA = TRUE, ... )"},{"path":"https://epiverse-trace.github.io/cfr/reference/prepare_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare common epidemiological data formats for CFR estimation — prepare_data","text":"data -like object. Currently, objects supported. may grouped. ... Currently unused. Passing extra arguments throw warning. cases_variable string name cases variable \"count_variable\" column data. deaths_variable string name deaths variable \"count_variable\" column data. fill_NA logical indicating whether NAs cases deaths data replaced 0s. default value TRUE, message make users aware replacement.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/prepare_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare common epidemiological data formats for CFR estimation — prepare_data","text":" suitable disease severity estimation functions provided cfr, columns \"date\", \"cases\", \"deaths\". Additionally, grouped data, columns representing grouping variables also present. result continuous sequence dates start end date data; required data passed functions cfr_static().","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/prepare_data.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Prepare common epidemiological data formats for CFR estimation — prepare_data","text":"method data can replace NAs case death data 0s using fill_NA argument, TRUE default, meaning NAs replaced. Keeping NAs cause downstream issues calling functions cfr_static() data, handle NAs. Setting fill_NA = TRUE resolves issue. Passing grouped object data result function respecting grouping returning grouping variables separate columns.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/prepare_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare common epidemiological data formats for CFR estimation — prepare_data","text":"","code":"#### For data #### # load Covid-19 data from incidence2 covid_uk <- incidence2::covidregionaldataUK # convert to incidence2 object covid_uk_incidence <- incidence2::incidence( covid_uk, date_index = \"date\", counts = c(\"cases_new\", \"deaths_new\"), count_names_to = \"count_variable\" ) #> Warning: `cases_new` contains NA values. Consider imputing these and calling `incidence()` again. # View tail of prepared data data <- prepare_data( covid_uk_incidence, cases_variable = \"cases_new\", deaths_variable = \"deaths_new\" ) #> NAs in cases and deaths are being replaced with 0s: Set `fill_NA = FALSE` to prevent this. tail(data) #> date cases deaths #> 485 2021-05-28 6205 6 #> 486 2021-05-29 5146 5 #> 487 2021-05-30 5395 8 #> 488 2021-05-31 6251 6 #> 489 2021-06-01 3346 4 #> 490 2021-06-02 0 0 #### For grouped data #### # convert data to incidence2 object grouped by region covid_uk_incidence <- incidence2::incidence( covid_uk, date_index = \"date\", counts = c(\"cases_new\", \"deaths_new\"), count_names_to = \"count_variable\", groups = \"region\" ) #> Warning: `cases_new` contains NA values. Consider imputing these and calling `incidence()` again. # View tail of prepared data data <- prepare_data( covid_uk_incidence, cases_variable = \"cases_new\", deaths_variable = \"deaths_new\" ) #> NAs in cases and deaths are being replaced with 0s: Set `fill_NA = FALSE` to prevent this. tail(data) #> date region cases deaths #> 6365 2021-06-02 Scotland 0 0 #> 6366 2021-06-02 South East 0 0 #> 6367 2021-06-02 South West 0 0 #> 6368 2021-06-02 Wales 0 0 #> 6369 2021-06-02 West Midlands 0 0 #> 6370 2021-06-02 Yorkshire and The Humber 0 0"},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"cfr-013","dir":"Changelog","previous_headings":"","what":"cfr 0.1.3","title":"cfr 0.1.3","text":"Added vignette estimate_from_individual_data.Rmd describing relationship individual-level data aggregate estimation.","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"cfr-012","dir":"Changelog","previous_headings":"","what":"cfr 0.1.2","title":"cfr 0.1.2","text":"CRAN release: 2024-09-26 Updated version fix instability normal approximation displayed Ebola example. release includes: Removal normal approximation .estimate_severity() function, instead using binomial likelihood unless criteria Poisson approximation met. Updated README example focusing first 30 days outbreak, emphasise effects accounting delays outcome.","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"cfr-011","dir":"Changelog","previous_headings":"","what":"cfr 0.1.1","title":"cfr 0.1.1","text":"CRAN release: 2024-06-12 Maintainer changing @adamkucharski (#143).","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"major-changes-0-1-1","dir":"Changelog","previous_headings":"","what":"Major changes","title":"cfr 0.1.1","text":"output column names severity_mean ascertainment_mean corrected severity_estimate ascertainment_estimate. may break workflows rely previous column names (#146). version cfr includes changes severity estimation algorithms used calculating static severity measure, may lead small changes CFR values calculated using v0.1.0 (#129).","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"functions-0-1-1","dir":"Changelog","previous_headings":"","what":"Functions","title":"cfr 0.1.1","text":"cfr_static(): informative checks intermediate values passed .estimate_severity(). Prints message CFR value determined unreliable. cfr_rolling(): Prints message explaining convenience function. improved input checking. Uses new .estimate_severity() functionality based outbreak size initial expectation CFR (#129). Prints message rolling CFR values determined unreliable. .estimate_severity(): Renamed . prefix indicate internal function. Added parameter p_mid initial severity estimate, used determine likelihood approximation method. Selects among Binomial, Poisson, Normal approximation likelihood depending outbreak size p_mid using function .select_fun_likelihood(); prints message selected method (#129). Lowest possible severity estimate reduced 10−410^{-4}. Severity estimates confidence intervals stored named vectors rather . .select_func_likelihood(): Internal function added chooses likelihood approximation function based outbreak size p_mid. Binomial approximation used small outbreaks cumulative cases lower Poisson threshold. Poisson approximation used outbreaks Poisson threshold p_mid < 0.05. Normal approximation used outbreaks Poisson threshold p_mid > 0.05. test_fn_req_args() updated use Reduce(f = \"+\") Map() rather sum(mapply()).","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"documentation-0-1-1","dir":"Changelog","previous_headings":"","what":"Documentation","title":"cfr 0.1.1","text":"Added package level documentation. Updated Readme lifecycle (stable) RepoStatus (Active) badges (#113), added DPG badge (#127), updated related projects section; corrected figure labelling (#114). Updated _pkgdown.yaml manual Bootstrap version (#136) reference sections, added software permissions vignette (#125), enabled development mode (#143). Updated WORDLIST. Updated function documentation files (#134). Added section distributions vignette acceptable use continuous rather discrete distributions. Corrected explanation estimate_outcomes() static severity vignette added explanations profile likelihood generation methods used severity vignettes (#143). Corrected equations vignettes (#133) removed .estimate_severity() vignettes (#132).","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"tests-0-1-1","dir":"Changelog","previous_headings":"","what":"Tests","title":"cfr 0.1.1","text":"snapshots updated severity values new likelihood functions (#129). Added session global state checker script setup options script (#119). tests updated reflect functions sometimes throw informative messages. Tests using incidence2 suppress warnings missing values (added incidence2 v2.3.0) filling missing values subject test prepare_data.incidence2() (#143).","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"package-0-1-1","dir":"Changelog","previous_headings":"","what":"Package","title":"cfr 0.1.1","text":"Added updated GitHub Actions workflows dependency changes, linting, updating citation file, updating license year (#119, #137, #142). Updated GHA workflows infrastructure files match latest versions epiverse-trace/packagetemplate (#119). Normalised DESCRIPTION file. Added tools/check.env epiverse-trace/packagetemplate suppress specific checks package size, Rd cross references, GNU Make requirement, non-ASCII strings (#142).","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"cfr-010","dir":"Changelog","previous_headings":"","what":"cfr 0.1.0","title":"cfr 0.1.0","text":"CRAN release: 2023-11-21 Initial CRAN submission cfr, R package estimate severity disease ascertainment cases correcting delays outcomes reported cases known. release includes: Functions overall severity outbreak, overall severity outbreak estimated expanding time series data, time-varying severity outbreak, function estimate number outcomes expected given number cases assuming user-specified distribution delays cases outcomes known, function estimate overall (static) ascertainment cases outbreak comparing relevant severity measures user-specified baseline severity, data preparation generic S3 method class incidence2 package, Example daily case death data 1976 Ebola Virus Disease outbreak reported Camacho et al. (2014). https://doi.org/10.1016/j.epidem.2014.09.003, Example daily case death data Covid-19 pandemic range 2020-01-01 2022-12-31 19 countries 100,00 deaths period, taken covidregionaldata package longer CRAN, Vignettes describing get started severity estimation, detailed workflows different kinds severity estimation, vignette working data incidence2 package, vignette working delay distributions, 100% code coverage, Workflows render vignettes README website.","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"correction-0-1-0","dir":"Changelog","previous_headings":"","what":"Correction","title":"cfr 0.1.0","text":"cfr v0.1.0 includes functionality static ascertainment calculations. functionality time-varying ascertainment expected included future versions, older implementation removed just prior release. news section cfr v0.1.0 updated reflect .","code":""}] +[{"path":"https://epiverse-trace.github.io/cfr/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to cfr","title":"Contributing to cfr","text":"outlines propose change cfr.","code":""},{"path":"https://epiverse-trace.github.io/cfr/CONTRIBUTING.html","id":"making-changes","dir":"","previous_headings":"","what":"Making changes","title":"Contributing to cfr","text":"want make change, ’s good idea first file issue make sure someone team agrees ’s needed. ’ve found bug, please file issue illustrates bug minimal reprex (also help write unit test, needed). See bug report template. feature request see feature request.","code":""},{"path":"https://epiverse-trace.github.io/cfr/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"Making changes","what":"Pull request process","title":"Contributing to cfr","text":"See pull request template Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"epiverse-trace/cfr\", fork = TRUE). Install development dependencies devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"https://epiverse-trace.github.io/cfr/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"Making changes","what":"Code style","title":"Contributing to cfr","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"https://epiverse-trace.github.io/cfr/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to cfr","text":"Please note cfr project released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"https://epiverse-trace.github.io/cfr/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 cfr authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"use-case","dir":"Articles","previous_headings":"","what":"Use case","title":"Estimating disease severity while correcting for reporting delays","text":"disease outbreak underway. want know severe disease terms case fatality risk (CFR), delay cases reported, outcomes cases — whether recovery death — known. reporting delay, can accounted knowing reporting delay past outbreaks.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"what-we-have","dir":"Articles","previous_headings":"","what":"What we have","title":"Estimating disease severity while correcting for reporting delays","text":"time-series cases deaths, (cases may substituted another indicator infections time); Data distribution delays, describing probability individual die tt days initially infected.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"what-we-assume","dir":"Articles","previous_headings":"","what":"What we assume","title":"Estimating disease severity while correcting for reporting delays","text":"data reporting delays past outbreaks informative reporting delays current outbreak.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"case-and-death-data","dir":"Articles","previous_headings":"","what":"Case and death data","title":"Estimating disease severity while correcting for reporting delays","text":"Data cases deaths may obtained number publicly accessible sources, global Covid-19 dataset curated World Data, similar dataset made available R package covidregionaldata (Palmer et al. 2021), data outbreaks infections made available outbreaks. outbreak response scenario, data may also compiled shared locally. See vignette working data incidence2 working common format incidence data can help interoperability formats. cfr package requires data frame three columns, “date”, “cases”, “deaths”, giving daily number reported cases deaths. , use data first Ebola outbreak, Democratic Republic Congo 1976, included package (Camacho et al. 2014).","code":"data(\"ebola1976\") # view ebola dataset head(ebola1976) #> date cases deaths #> 1 1976-08-25 1 0 #> 2 1976-08-26 0 0 #> 3 1976-08-27 0 0 #> 4 1976-08-28 0 0 #> 5 1976-08-29 0 0 #> 6 1976-08-30 0 0"},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"obtaining-data-on-reporting-delays","dir":"Articles","previous_headings":"","what":"Obtaining data on reporting delays","title":"Estimating disease severity while correcting for reporting delays","text":"obtain disease’s onset--death distribution recent Ebola outbreak, reported Barry et al. (2018). onset--death distribution considered Gamma distributed, shape kk = 2.40 scale θ\\theta = 3.33. Note use continuous distribution , appropriate use discrete distribution instead working daily data. Note also use central estimates distribution parameter, ignoring uncertainty parameters uncertainty resulting CFR likely underestimated. forthcoming epiparameter package aims library epidemiological delay distributions, can accessed easily within workflows. See vignette using delay distributions information use distribution objects supported R prepare delay density functions.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"estimate-disease-severity","dir":"Articles","previous_headings":"","what":"Estimate disease severity","title":"Estimating disease severity while correcting for reporting delays","text":"use function cfr_static() calculate overall disease severity latest date outbreak. cfr_static() function well suited small outbreaks relatively events time period consideration relatively brief, severity unlikely changed time. understand severity changed time (e.g. following vaccination pathogen evolution), use function cfr_time_varying(). function however well suited small outbreaks requires sufficiently many cases time estimate CFR changes. can found vignette estimating disease severity varies course outbreak.","code":"cfr_static( data = ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) #> severity_estimate severity_low severity_high #> 1 0.9592 0.9295 0.9793"},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"estimate-ascertainment-ratio","dir":"Articles","previous_headings":"","what":"Estimate ascertainment ratio","title":"Estimating disease severity while correcting for reporting delays","text":"important know proportion cases outbreak ascertained muster appropriate response, estimate overall burden outbreak. Note ascertainment ratio may affected number factors. main factor low ascertainment lack (access ) testing capacity, refer reporting -reporting. estimate_ascertainment() function estimates ascertainment ratio using daily case death data, known severity disease previous outbreaks, optionally delay distribution onset--death. , estimate reporting 1976 Ebola outbreak Congo, assuming Ebola virus disease (time) baseline severity 0.7 (70% cases result deaths), based CFR values estimated later, larger datasets. use onset--death distribution Barry et al. (2018). analysis suggests 70% 83% cases reported outbreak. details can found vignette estimating proportion cases reported outbreak.","code":"# estimate reporting with a baseline severity of 70% estimate_ascertainment( data = ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33), severity_baseline = 0.7 ) #> ascertainment_estimate ascertainment_low ascertainment_high #> 1 0.7297748 0.7147963 0.7530931"},{"path":"https://epiverse-trace.github.io/cfr/articles/cfr.html","id":"concept-how-reporting-delays-bias-cfr-estimates","dir":"Articles","previous_headings":"","what":"Concept: How reporting delays bias CFR estimates","title":"Estimating disease severity while correcting for reporting delays","text":"Simply dividing number deaths number cases obtain CFR naive estimator true CFR. Suppose 10 people start showing symptoms disease given day end day remain alive. Suppose next 5 days, numbers new cases continue rise reach 100 new cases day 5. However, suppose day 5, infected individuals remain alive. naive estimate CFR calculated end first 5 days zero, zero deaths total — point. say, outcomes cases (deaths) known. Even deaths begin occur, lag ascertainment case hospitalisation outcome leads consistently biased estimate. Hence, adjusting delays using appropriate delay distribution essential accurate estimates severity.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"a-brief-primer-on-distributions-in-r","dir":"Articles","previous_headings":"","what":"A brief primer on distributions in R","title":"A primer on working with delay distributions","text":"R extension packages provide rich extensive support representing working probability distributions, can seen CRAN probability distributions task view. Users might already familiar distributions related functionality — probability density function, random number generation — provided stats package loaded R started. example, Gamma distribution’s probability density function (PDF) represented stats::dgamma().","code":"# the probability density function at `x` for a Gamma distribution dgamma(x = seq(10), shape = 5, rate = 1) #> [1] 0.01532831 0.09022352 0.16803136 0.19536681 0.17546737 0.13385262 #> [7] 0.09122619 0.05725229 0.03373716 0.01891664"},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"using-delay-distribution-densities-in-cfr","dir":"Articles","previous_headings":"","what":"Using delay distribution densities in cfr","title":"A primer on working with delay distributions","text":"correct reporting delays disease severity estimation, primarily interested PDF PMF (probability mass function) distribution reporting delays cases known outcomes. refer R functions providing PDF PMF density distribution. delay distribution density must passed functions cfr_static(), cfr_time_varying(), estimate_ascertainment() via delay_density argument. can represented pseudo-code ","code":"cfr_*(data, delay_density = )"},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"preparing-delay-distribution-density-for-cfr","dir":"Articles","previous_headings":"","what":"Preparing delay distribution density for cfr","title":"A primer on working with delay distributions","text":"Importantly, cfr functions must receive delay density way density can calculated flexible number values (sequence days outbreak data). example, wrapping density function Gamma distribution within another function fixes distribution parameters accepts vector numbers, can evaluated set values specified vector. information working functions, especially anonymous functions, can found chapter Functional Programming Advanced R. Users working R > 4.1.0 can also use new syntax anonymous functions, e.g. \\(x) stats::dgamma(x, shape, scale). Note use central estimates distribution parameter, ignoring uncertainty parameters uncertainty resulting CFR likely underestimated.","code":"# wrap stats::dgamma() in a function # the Gamma distribution parameters are contained within dens_gamma() dens_gamma <- function(x) { stats::dgamma(x = x, shape = 5, scale = 1) } # check over a vector of `x` dens_gamma(x = seq(10)) #> [1] 0.01532831 0.09022352 0.16803136 0.19536681 0.17546737 0.13385262 #> [7] 0.09122619 0.05725229 0.03373716 0.01891664"},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"passing-delay-distribution-density-to-cfr-functions","dir":"Articles","previous_headings":"","what":"Passing delay distribution density to cfr functions","title":"A primer on working with delay distributions","text":"delay distribution density functions can passed, anonymous functions, cfr functions shown example data provided package Camacho et al. (2014). Parameters onset--death distribution Ebola virus disease taken Barry et al. (2018).","code":"# load package data data(\"ebola1976\") # pass function wrapping dgamma to cfr_static() cfr_static( data = ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) #> severity_estimate severity_low severity_high #> 1 0.9592 0.9295 0.9793"},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"using-other-distribution-representations","dir":"Articles","previous_headings":"","what":"Using other distribution representations","title":"A primer on working with delay distributions","text":"many R packages provide support representing probability distributions, focus two examples, distributional distcrete, show closures wrapping implemented, wrapping parameters Barry et al. (2018). Users may wish use similar packages better management distributions parameters. See CRAN probability distributions task view information distribution packages suitable different use cases.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"using-distributional","dir":"Articles","previous_headings":"Using other distribution representations","what":"Using distributional","title":"A primer on working with delay distributions","text":"Note output density(, x) list containing vector.","code":"# using {distributional} and parameters from Barry et al. 2018 dist_onset_to_death_ebola <- dist_gamma(shape = 2.40, rate = 1.0 / 3.33) # wrap function and pass it to cfr_static() # unlist() required as density(, x) is a list cfr_static( data = ebola1976, delay_density = function(x) unlist(density(dist_onset_to_death_ebola, x)) ) #> severity_estimate severity_low severity_high #> 1 0.9592 0.9295 0.9793"},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"using-distcrete","dir":"Articles","previous_headings":"Using other distribution representations","what":"Using distcrete","title":"A primer on working with delay distributions","text":"distcrete package provides support discrete distributions. , show example discrete Gamma distribution. Note density function objects encapsulated, can passed directly delay_density argument.","code":"# using {distcrete} and parameters from Barry et al. 2018 dist_onset_to_death_ebola <- distcrete( name = \"gamma\", shape = 2.40, scale = 3.33, interval = 1 ) # pass density function to cfr_static() cfr_static( data = ebola1976, delay_density = dist_onset_to_death_ebola$d ) #> severity_estimate severity_low severity_high #> 1 0.9576 0.9275 0.9782"},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"using-continuous-and-discrete-distributions","dir":"Articles","previous_headings":"","what":"Using continuous and discrete distributions","title":"A primer on working with delay distributions","text":"Note discrete distributions appropriate choice passed cfr_*(), usually working daily case death data. use continuous distributions many examples onset--death delays typically long large variance. Evaluating probability distribution function distributions discrete points (, days) similar evaluating probability mass function equivalent discrete distribution. However, note assumption may appropriate strongly peaked distributions, .e., onset--death strongly peaked low variance, difference PDF PMF likely larger average (spread distribution). , cfr functions tally estimated death counts (calculated convolving cases densities), underestimates due PDF-PMF discrepancy one end distribution help cancel overestimates end distribution.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/delay_distributions.html","id":"links-to-epiparameter","dir":"Articles","previous_headings":"","what":"Links to epiparameter","title":"A primer on working with delay distributions","text":"users can pass functions stats, can manage distribution parameters using specialised packages classes, may convenient able access parameters reported epidemiological literature curated library. forthcoming epiparameter package aims library epidemiological delay distributions. dedicated class expected similar functionality distribution classes, allowing easy definition density functions can passed cfr. pseudo-code shows might work.","code":"# NOTE: this is pseudo-code EPIPARAMETER_OBJECT <- ACCESS_DISTRIBUTION(disease, study) cfr_*(data = data, delay_density = function(x) density(, x))"},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_ascertainment.html","id":"use-case","dir":"Articles","previous_headings":"","what":"Use case","title":"Estimating the proportion of cases that are ascertained during an outbreak","text":"ascertainment cases outbreak perfect. want estimate proportion cases ascertained given case death data.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_ascertainment.html","id":"what-we-have","dir":"Articles","previous_headings":"","what":"What we have","title":"Estimating the proportion of cases that are ascertained during an outbreak","text":"time-series cases deaths, (cases may substituted another indicator infections time); Data distribution delays, describing probability individual die tt days initially infected.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_ascertainment.html","id":"ascertainment-for-the-covid-19-pandemic-in-the-u-k-","dir":"Articles","previous_headings":"","what":"Ascertainment for the Covid-19 pandemic in the U.K.","title":"Estimating the proportion of cases that are ascertained during an outbreak","text":"example shows ascertainment ratio estimation using cfr data Covid-19 pandemic United Kingdom. load example Covid-19 daily case death data provided cfr package covid_data, subset first six months U.K. data. obtain appropriate distribution reported Linton et al. (2020); log-normal distribution μ\\mu = 2.577 σ\\sigma = 0.440. Note Linton et al. (2020) fitted discrete lognormal distribution — use continuous distribution . See vignette delay distributions using continuous instead discrete distribution acceptable, using discrete distributions cfr. Note use central estimates distribution parameter, ignoring uncertainty parameters uncertainty resulting CFR likely underestimated.","code":"# get Covid data provided with the package data(\"covid_data\") # filter for the U.K df_covid_uk <- filter( covid_data, country == \"United Kingdom\", date <= \"2020-06-30\" ) # view the data format tail(df_covid_uk) #> date country cases deaths #> 175 2020-06-25 United Kingdom 883 97 #> 176 2020-06-26 United Kingdom 777 101 #> 177 2020-06-27 United Kingdom 726 108 #> 178 2020-06-28 United Kingdom 666 79 #> 179 2020-06-29 United Kingdom 653 73 #> 180 2020-06-30 United Kingdom 449 70"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_ascertainment.html","id":"estimating-the-proportion-of-cases-that-have-been-ascertained","dir":"Articles","previous_headings":"Ascertainment for the Covid-19 pandemic in the U.K.","what":"Estimating the proportion of cases that have been ascertained","title":"Estimating the proportion of cases that are ascertained during an outbreak","text":"use estimate_ascertainment() function calculate static CFR (internally), overall ascertainment Covid-19 pandemic U.K. assume “true” CFR Covid-19 0.014 (.e. 1.4%) (Verity et al. 2020). Future plans package include ability incorporate uncertainty CFR estimates calculating -ascertainment. Note CFR Verity et al. (2020) based lab-confirmed clinically diagnosed cases Wuhan, China. Since case definition U.K. different used , ascertainment ratio estimated likely biased. Furthermore, ignoring uncertainty estimate, ascertainment ratio likely -precise well.","code":"# static ascertainment on data estimate_ascertainment( data = df_covid_uk, delay_density = function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440), severity_baseline = 0.014 ) #> ascertainment_estimate ascertainment_low ascertainment_high #> 1 0.06779661 0.06734007 0.06829268"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_ascertainment.html","id":"ascertainment-in-countries-with-large-early-covid-19-pandemics","dir":"Articles","previous_headings":"","what":"Ascertainment in countries with large early Covid-19 pandemics","title":"Estimating the proportion of cases that are ascertained during an outbreak","text":"Finally, estimate ascertainment countries least 100,000 reported Covid-19 deaths 2020 2023, focus period start outbreak 1st June 2020. now use larger dataset covid_data made available cfr package. exclude four countries provide weekly data (zeros dates ), plot ascertainment country remaining. Example plot ascertainment ratio country early stages Covid-19 pandemic.","code":"# countries with weekly reporting weekly_reporting <- c(\"France\", \"Germany\", \"Spain\", \"Ukraine\") # subset for early covid outbreaks covid_data_early <- filter( covid_data, date < \"2020-06-01\", !country %in% weekly_reporting ) # nest the data df_reporting <- nest(covid_data_early, .by = country) # define density function delay_density <- function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440) # calculate the reporting rate in each country using # map on nested dataframes df_reporting <- mutate( df_reporting, reporting = map( .x = data, .f = estimate_ascertainment, # arguments to function severity_baseline = 0.014, delay_density = delay_density ) ) #> Total cases = 405843 and p = 0.0171: using Poisson approximation to binomial likelihood. #> Total cases = 30967 and p = 0.0433: using Poisson approximation to binomial likelihood. #> Total cases = 163103 and p = 0.031: using Poisson approximation to binomial likelihood. # unnest the data df_reporting <- unnest(df_reporting, cols = \"reporting\") # visualise the data head(df_reporting) #> # A tibble: 6 × 5 #> country data ascertainment_estimate ascertainment_low ascertainment_high #> #> 1 Argentina 0.130 0.124 0.137 #> 2 Brazil 0.112 0.111 0.113 #> 3 Colombia 0.236 0.222 0.252 #> 4 India 0.253 0.247 0.260 #> 5 Indonesia 0.153 0.146 0.161 #> 6 Iran 0.215 0.211 0.219 df_reporting %>% ggplot() + geom_pointrange( aes( x = fct_reorder(country, ascertainment_estimate), y = ascertainment_estimate, ymin = ascertainment_low, ymax = ascertainment_high ) ) + coord_flip() + labs(x = NULL, y = \"Ascertainment ratio\") + theme(legend.position = \"none\") + scale_y_continuous( labels = percent, limits = c(0, 1) ) + theme_classic() + theme(legend.position = \"top\")"},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"use-case","dir":"Articles","previous_headings":"","what":"Use case","title":"Estimating fatality risk from individual level data","text":"want estimate case fatality risk (CFR) individual-level linelist data.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"what-we-have","dir":"Articles","previous_headings":"","what":"What we have","title":"Estimating fatality risk from individual level data","text":"linelist case onset timings, well either individual outcome (.e. death, recovery) occurred point recorded, total deaths. Data distribution delay onset--death, describing probability individual die tt days initially infected.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"estimation-based-on-cases-with-known-outcomes","dir":"Articles","previous_headings":"","what":"Estimation based on cases with known outcomes","title":"Estimating fatality risk from individual level data","text":"individual-level data case onset timings outcomes, available, common filter data focus cases known outcomes. means case fatality risk can calculated filtered dataset containing known outcomes: Total deathsTotal deaths+Total recoveries \\frac{\\text{Total deaths}}{\\text{Total deaths}+ \\text{Total recoveries}} One limitation method implicitly assumes delay onset--death onset--recovery (see mathematical proof). delays noticeably different, calculation produce biased estimate CFR. example, onset--recovery much longer onset--death, given time point mid-outbreak, denominator underestimate true number cases eventually recover similar onset timings eventually die. Hence calculation inflate CFR estimate. mathematical explanation , next section discuss estimation methods based expected number known death outcomes using functionality cfr.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"mathematical-explanation-for-bias","dir":"Articles","previous_headings":"Estimation based on cases with known outcomes","what":"Mathematical explanation for bias","title":"Estimating fatality risk from individual level data","text":"linelist known outcomes onset-death delay follows distribution onset-recovery, CFR = pp, current time, E(Total deaths date)=∑tp∑jfjIt−j E(\\text{Total deaths date}) = \\sum_{t} p \\sum_j f_{j} I_{t-j} E(Total recoveries date)=∑t(1−p)∑jfjIt−j E(\\text{Total recoveries date}) = \\sum_{t}(1-p) \\sum_j f_{j} I_{t-j} ItI_t number new symptomatic infections day tt fif_i probability outcome ii days symptom onset. Hence $$ E(\\text{Total deaths})/ [ E(\\text{Total deaths})+E(\\text{Total recoveries}) ] \\\\ = [ \\sum_{t} p \\sum_j f_{j} I_{t-j} ]/[ \\sum_{t} p \\sum_j f_{j} I_{t-j} + \\sum_{t}(1-p) \\sum_j f_{j} I_{t-j}] \\\\ = [p \\sum_{t} \\sum_j f_{j} I_{t-j} ]/[ \\sum_{t} \\sum_j f_{j} I_{t-j} ] = p $$ However, delay death fjDf_j^D different delay recovery fjRf_j^R, : E(Total deaths)/[E(Total deaths)+E(Total recoveries)]=∑t∑jpfjDIt−j∑t∑jpfjDIt−j+∑t∑j(1−p)fjRIt−j E(\\text{Total deaths})/ [ E(\\text{Total deaths})+E(\\text{Total recoveries}) ] = \\frac{\\sum_{t} \\sum_j p f_j^D I_{t-j}}{\\sum_{t} \\sum_j p f_j^D I_{t-j} + \\sum_{t} \\sum_j (1-p) f_j^R I_{t-j}} hence simplify provide unbiased estimate pp, fjD=fjRf_j^D = f_j^R.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"estimation-based-on-expected-number-of-known-death-outcomes","dir":"Articles","previous_headings":"","what":"Estimation based on expected number of known death outcomes","title":"Estimating fatality risk from individual level data","text":"delay onset--death onset--recovery different, one option use survival analysis methods estimate relative hazards (.e. fatality risk) time. However, interested overall estimate CFR, simpler alternative first calculate number cases linelist expect known outcome point outcome fatal: E(deaths time t)=p∑t∑jfjIt−j E(\\text{deaths time }t) = p \\sum_{t} \\sum_j f_{j} I_{t-j} pp CFR. can rearrange calculate CFR: $$ \\text{Total deaths} = p \\sum_{t} \\sum_j f_{j} I_{t-j} \\\\ p = \\frac{\\text{Total deaths}}{\\sum_{t} \\sum_j f_{j} I_{t-j} } $$ calculation performed cfr_static(), hence function can give us better estimate CFR delays death recovery .","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"simulated-comparison-of-above-methods","dir":"Articles","previous_headings":"","what":"Simulated comparison of above methods","title":"Estimating fatality risk from individual level data","text":"compare methods, .e. filtering cases without known outcomes vs using cfr_static function, first simulate 1000 case onset timings outcomes (.e. deaths recoveries) Individual level timings onsets outcomes, individuals known outcome 20th Jan 2024. First, calculate CFR filtering focus cases known outcomes: Next, calculate CFR based expected fatal outcomes known date, using cfr_static() Hence particular simulation, cfr_static() method recovers correct CFR 10% (95% CI: 8.3-12.0%), whereas filtering method produces biased estimate 26.4% (17.6-37.0%).","code":"# Simulate data nn <- 1e3 # Number of cases to simulate pp <- 0.1 # Assumed CFR set.seed(10) # Set seed for reproducibility # Generate random case onset timings in Jan & Feb 2024 case_onsets <- as.Date(\"2024-01-01\") + sample(1:60, nn, replace = TRUE) # Define current date of data availability (i.e. max follow up) max_obs <- as.Date(\"2024-01-20\") # Sample delays from onset to outcome # 1. Deaths: assume mean delay = 5 days, sd = 5 days log_param <- c(meanlog = 1.262864, sdlog = 0.8325546) delay_death <- function(x) { dlnorm(x, meanlog = log_param[[\"meanlog\"]], sdlog = log_param[[\"sdlog\"]] ) } outcome_death <- round(rlnorm(round(nn * pp), meanlog = log_param[[\"meanlog\"]], sdlog = log_param[[\"sdlog\"]] )) # 2. Recoveries: assume mean delay = 15 days, sd = 5 days log_param <- c(meanlog = 2.65537, sdlog = 0.3245928) outcome_recovery <- round(rlnorm(round(nn * (1 - pp)), meanlog = log_param[[\"meanlog\"]], sdlog = log_param[[\"sdlog\"]] )) # Create vector of outcome dates all_outcomes <- case_onsets + c(outcome_death, outcome_recovery) # Create vector of outcome types type_outcome <- c(rep(\"D\", length(outcome_death)), rep(\"R\", length(outcome_recovery))) # Create vector of known outcomes as of max_obs known_outcomes <- type_outcome known_outcomes[(all_outcomes > max_obs)] <- \"\" # Create a data frame with onset and outcome dates, and outcome type data <- data.frame( id = 1:nn, case_onsets = case_onsets, outcome_dates = all_outcomes, outcome_type = type_outcome, known_outcome = known_outcomes ) # Filter out unknown outcomes (after the max_obs date) data <- data %>% filter(known_outcome != \"\") # Arrange data by onset date data <- data %>% arrange(case_onsets) %>% mutate(id_ordered = row_number()) # Assign a new 'id_ordered' # Prepare data for plotting (onset and outcome events in same column) plot_data <- data %>% tidyr::pivot_longer( cols = c(case_onsets, outcome_dates), names_to = \"event_type\", values_to = \"date\" ) %>% mutate( event_label = ifelse(event_type == \"case_onsets\", \"Onset\", \"Outcome\") ) # Create plot with lines linking onset and outcome ggplot() + geom_segment( data = data, aes(x = case_onsets, xend = outcome_dates, y = id_ordered, yend = id_ordered), color = ifelse(data$outcome_type == \"D\", \"red\", \"green\"), size = 0.5 ) + geom_point(data = plot_data, aes(x = date, y = id_ordered, color = outcome_type, shape = event_label), size = 2) + geom_vline(xintercept = as.numeric(max_obs), linetype = \"dashed\", color = \"black\", size = 0.5) + scale_color_manual(values = c(D = \"darkred\", R = \"darkgreen\")) + scale_shape_manual(values = c(Onset = 16, Outcome = 17)) + labs( x = \"Date\", y = \"Individual (Ordered by onset date)\", color = \"Outcome type\", shape = \"Event type\" ) + theme_minimal() #> Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. #> ℹ Please use `linewidth` instead. #> This warning is displayed once every 8 hours. #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was #> generated. # Filter on known outcomes total_deaths <- sum(known_outcomes == \"D\") total_outcomes <- (total_deaths + sum(known_outcomes == \"R\")) # Calculate CFR with 95% CI cfr_filter <- binom.test(total_deaths, total_outcomes) cfr_estimate <- (signif(as.numeric(c(cfr_filter$estimate, cfr_filter$conf.int)), 3)) cfr_estimate #> [1] 0.264 0.176 0.370 # Get times of death for fatal outcomes death_times <- (case_onsets)[type_outcome == \"D\"] + outcome_death # Create a single data.frame with event types events <- data.frame( dates = c(case_onsets, death_times), event = c(rep(\"cases\", length(case_onsets)), rep(\"deaths\", length(death_times))) ) # Use incidence2 to calculate counts of cases and deaths by day counts <- incidence2::incidence(events, date_index = \"dates\", groups = \"event\", complete_dates = TRUE) # Pivot incidence object to get data.frame with counts for cases and deaths df <- counts %>% tidyr::pivot_wider(names_from = event, values_from = count, values_fill = 0) %>% dplyr::rename(date = date_index) cfr_static(df, delay_death) #> severity_estimate severity_low severity_high #> 1 0.1042 0.086 0.1245"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"deaths-reported-but-not-recoveries","dir":"Articles","previous_headings":"","what":"Deaths reported but not recoveries","title":"Estimating fatality risk from individual level data","text":"extreme scenario recoveries reported, effectively values outcome_recovery generated distribution infinite mean, conclusions still apply, bias filtering approach. particular, expect: $$ E(\\text{Total deaths})/ [ E(\\text{Total deaths}) + E(\\text{Total recoveries}) ] \\rightarrow 1 \\\\ \\text{} E(\\text{Total recoveries}) \\rightarrow 0 $$ hence calculated CFR incorrectly converge 1 proportion recoveries reported declines 0.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"only-total-deaths-reported","dir":"Articles","previous_headings":"","what":"Only total deaths reported","title":"Estimating fatality risk from individual level data","text":"situations, may time series cases deaths. However, can still use earlier calculation derive unbiased CFR: $$ E(\\text{Total deaths}) = p \\sum_{t} \\sum_j f_{j} I_{t-j} \\\\ E(p) = \\frac{\\text{Total deaths}}{\\sum_{t} \\sum_j f_{j} I_{t-j} } $$ can cfr using estimate_outcomes() function calculate expected number cases known fatal outcomes denominator: , produces point estimate 10.4%, underlying method: internal function code cfr_static(), calls estimate_outcomes(), also tallies total death. arguably elegant approach therefore add total deaths case data.frame, use input cfr_static():","code":"# Calculate total deaths and total cases total_deaths <- sum(df$deaths) total_cases <- sum(df$cases) # Create data.frame with cases over time only df_case <- df df_case$deaths <- 0 # Calculate the expected number of known fatal outcomes over time e_outcomes <- estimate_outcomes(df_case, delay_death) # Calculate the CFR total_deaths / (total_cases * tail(e_outcomes$u_t, 1)) #> [1] 0.1042066 # Create data.frame with cases over time only df_cases <- df df_cases$deaths <- 0 # Add total deaths to the final row in the 'deaths' column df_cases$deaths[nrow(df_cases)] <- sum(df$deaths) # Calculate CFR cfr_static(df_cases, delay_death) #> severity_estimate severity_low severity_high #> 1 0.1042 0.086 0.1245"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_from_individual_data.html","id":"only-total-cases-and-deaths-reported","dir":"Articles","previous_headings":"","what":"Only total cases and deaths reported","title":"Estimating fatality risk from individual level data","text":"total cases total deaths known, possible adjust delays outcome. However, can bound estimate CFR two extreme scenarios. First, outbreak , sufficient time passed fatal outcomes now known, .e. ∑t∑jfjIt−j=∑tIt \\sum_{t} \\sum_j f_{j} I_{t-j} = \\sum_{t} I_t CFR equal : p=Total deathsTotal cases p = \\frac{\\text{Total deaths}}{\\text{Total cases}} contrast, epidemic rapidly growing still early stages, even epidemic CFR 1 may generated small number fatal outcomes date. Hence following bounds possible CFR: Total deathsTotal cases≤p≤1 \\frac{\\text{Total deaths}}{\\text{Total cases}} \\leq p \\leq 1 words, rapidly growing epidemic, can say CFR lies somewhere ratio total deaths total cases (last known count) 1 (worst-case scenario).","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"use-case","dir":"Articles","previous_headings":"","what":"Use case","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"want static estimate severity outbreak form case fatality risk (CFR) correcting delay reporting outcomes cases.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"what-we-have","dir":"Articles","previous_headings":"","what":"What we have","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"time-series cases deaths, (cases may substituted another indicator infections time); Data distribution delays, describing probability individual die tt days initially infected.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"severity-of-the-1976-ebola-outbreak","dir":"Articles","previous_headings":"","what":"Severity of the 1976 Ebola Outbreak","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"example data comes 1976 Ebola virus disease (EVD, Ebola) outbreak Democratic Republic Congo (Camacho et al. 2014). focus roughly first half dataset, subsetting data include days 30th September, 1976.","code":"data(\"ebola1976\") # view the first few rows head(ebola1976) #> date cases deaths #> 1 1976-08-25 1 0 #> 2 1976-08-26 0 0 #> 3 1976-08-27 0 0 #> 4 1976-08-28 0 0 #> 5 1976-08-29 0 0 #> 6 1976-08-30 0 0 df_ebola_subset <- filter(ebola1976, date <= \"1976-09-30\")"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"onset-to-death-delay-distribution","dir":"Articles","previous_headings":"Severity of the 1976 Ebola Outbreak","what":"Onset-to-death delay distribution","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"retrieve parameters distribution durations (also called delays) onset EVD symptoms death literature (Barry et al. 2018). Gamma distribution shape kk = 2.40 scale θ\\theta = 3.33. Note shall use continuous distribution , appropriate use discrete distribution instead working daily data. See vignette delay distributions using continuous instead discrete distribution acceptable, using discrete distributions cfr. Note also use central estimates distribution parameter, ignoring uncertainty parameters uncertainty resulting CFR likely underestimated.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"intermediate-step-estimating-cases-with-known-outcomes","dir":"Articles","previous_headings":"Severity of the 1976 Ebola Outbreak","what":"Intermediate step: Estimating cases with known outcomes","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"function estimate_outcomes() estimates number cases whose outcomes expected known day ii outbreak, given time-series case onsets distribution delays symptom onset case outcome. context CFR estimation, delay distribution usually ‘onset--death’ distribution. resulting data frame contains two new columns, “estimated_outcomes”, number cases whose outcomes expected known day, “u_t” ratio cumulative number cases estimated known outcomes cumulative number cases reported date specified data. estimated outcomes lower number cases beginning outbreak case outcomes likely become known days later; also means u_t likely lower 1.0 early outbreak. u_t outbreak ended much closer 1.0, outcomes reported cases expected known (depending quality outbreak monitoring). depends distribution delays onset outcome, ratio u_t ‘catch ’ 1.0 faster onset--outcome delay short. Note period onset death may shorter period onset full recovery, considered equivalent. CFR estimation, primarily interested former goal estimating severity form fatality risk (ratio past outbreaks). Note estimate_outcomes() exported primarily intended internal use.","code":"# calculate known death outcomes df_estimated_outcomes_ebola <- estimate_outcomes( data = df_ebola_subset, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) # print head of data frame head(df_estimated_outcomes_ebola) #> date cases deaths estimated_outcomes u_t #> 1 1976-08-25 1 0 0.00000000 0.00000000 #> 2 1976-08-26 0 0 0.03323030 0.03323030 #> 3 1976-08-27 0 0 0.06494676 0.09817706 #> 4 1976-08-28 0 0 0.08485286 0.18302992 #> 5 1976-08-29 0 0 0.09400738 0.27703731 #> 6 1976-08-30 0 0 0.09515185 0.37218916 # print tail of data frame tail(df_estimated_outcomes_ebola) #> date cases deaths estimated_outcomes u_t #> 32 1976-09-25 11 8 7.787856 0.5283224 #> 33 1976-09-26 7 11 8.301252 0.5563894 #> 34 1976-09-27 7 7 8.625233 0.5840532 #> 35 1976-09-28 4 13 8.761617 0.6207698 #> 36 1976-09-29 4 12 8.659704 0.6552761 #> 37 1976-09-30 3 9 8.371787 0.6904737"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"estimating-the-naive-and-corrected-cfr","dir":"Articles","previous_headings":"Severity of the 1976 Ebola Outbreak","what":"Estimating the naive and corrected CFR","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"function cfr_static() wraps internal function estimate_outcomes() provide static CFR automatically correcting reporting delays delay density function provided.","code":"# calculating the naive CFR cfr_static( data = df_ebola_subset ) #> severity_estimate severity_low severity_high #> 1 0.7197802 0.6485503 0.7836984 # calculating the corrected CFR cfr_static( df_ebola_subset, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) #> severity_estimate severity_low severity_high #> 1 NA NA NA"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"severity-estimation-methods","dir":"Articles","previous_headings":"","what":"Severity estimation methods","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"cfr_static() automatically chooses method calculating severity estimate, based whether delay correction applied, delay correction applied, depending total number cases initial rough estimate severity. Naive estimate: delay correction applied, CFR ratio total deaths total cases, confidence interval given Binomial test using stats::binom.test() total deaths successes, total cases trials, hypothesised success 1.0 Delay correction, small outbreaks: outbreaks total cases user-specified ‘Poisson threshold’ (poisson_threshold, default = 100), CFR uncertainty around taken profile likelihood generated Binomial model deaths (successes) estimated known outcomes (trials). Delay correction, large outbreaks low severity: outbreaks total cases greater Poisson threshold (default = 100) initial severity estimates < 0.05, CFR uncertainty taken Poisson approximation Binomial profile likelihood (taking λ\\lambda = npnp nn estimated outcomes pp severity estimate). Delay correction, large outbreaks higher severity: outbreaks total cases greater Poisson threshold (default = 100) initial severity estimates ≥\\geq 0.05, CFR uncertainty taken Normal approximation Binomial profile likelihood.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"severity-of-the-covid-19-pandemic-in-the-u-k-","dir":"Articles","previous_headings":"","what":"Severity of the COVID-19 pandemic in the U.K.","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"example shows static severity estimation using cfr data Covid-19 pandemic United Kingdom. load example Covid-19 daily case death data provided cfr package covid_data, subset first year U.K. data.","code":"# get Covid data loaded with the package data(\"covid_data\") # filter for the U.K df_covid_uk <- filter( covid_data, country == \"United Kingdom\", date <= \"2020-12-31\" ) # View the first few rows and recall necessary columns: date, cases, deaths head(df_covid_uk) #> date country cases deaths #> 1 2020-01-03 United Kingdom 0 0 #> 2 2020-01-04 United Kingdom 0 0 #> 3 2020-01-05 United Kingdom 0 0 #> 4 2020-01-06 United Kingdom 0 0 #> 5 2020-01-07 United Kingdom 0 0 #> 6 2020-01-08 United Kingdom 0 0"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"onset-to-death-distribution-for-covid-19","dir":"Articles","previous_headings":"Severity of the COVID-19 pandemic in the U.K.","what":"Onset-to-death distribution for Covid-19","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"retrieve appropriate distribution Covid-19 Linton et al. (2020); lognormal distribution μ\\mu = 2.577 σ\\sigma = 0.440. Note Linton et al. (2020) fitted discrete lognormal distribution use continuous distribution, ignoring uncertainty distribution parameters hence likely -estimating uncertainty CFR.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"estimating-the-naive-and-corrected-cfr-1","dir":"Articles","previous_headings":"Severity of the COVID-19 pandemic in the U.K.","what":"Estimating the naive and corrected CFR","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"Finally, calculate naive corrected CFRs Covid-19 pandemic U.K.","code":"# calculating the naive CFR cfr_static( df_covid_uk ) #> severity_estimate severity_low severity_high #> 1 0.03640132 0.03617238 0.0366313 # calculating the corrected CFR cfr_static( df_covid_uk, delay_density = function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440) ) #> severity_estimate severity_low severity_high #> 1 0.0465 0.0462 0.0467"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_static_severity.html","id":"details-adjusting-for-delays-between-two-time-series","dir":"Articles","previous_headings":"","what":"Details: Adjusting for delays between two time series","title":"Calculating a static, delay-adjusted estimate of disease severity","text":"cfr_static() follows Nishiura et al. (2009) calculate quantity utu_t day within input data represents proportion cases known adverse outcome (usually death) day tt. ut=∑=0t∑j=0∞ci−jfj∑=0ci, u_t = \\dfrac{\\sum_{= 0}^t \\sum_{j = 0}^\\infty c_{- j} f_{j}}{\\sum_{= 0} c_i}, ftf_t value probability mass function time tt, ctc_t, dtd_t number new cases new deaths time tt (respectively). use utu_t following likelihood function estimate severity. $$ {\\sf L}(\\theta | C_{t},D_{t},u_{t}) = \\log{\\dbinom{u_{t}C_{t}}{D_{t}}} + D_{t} \\log{\\theta} + (u_{t}C_{t} - D_{t})\\log{(1 - \\theta)}, $$ CtC_{t} DtD_{t} cumulative number cases deaths (respectively) time tt. Lastly θ\\theta (severity) estimated θ\\theta using simple maximum-likelihood methods, allowing functions within package quick easy tools use. precise severity measure — CFR, IFR, HFR, etc — θ\\theta represents depends upon input data given user. Case fatality risk (CFR) requires case death incidence data, case--death delay distribution (close approximation, symptom onset--death). Infection fatality risk (IFR) requires infection death incidence data, exposure--death delay distribution (close approximation). Hospitalisation Fatality Risk (HFR) requires hospitalisation death incidence data, appropriate delay distribution (close approximation).","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"use-case","dir":"Articles","previous_headings":"","what":"Use case","title":"Estimating how disease severity varies over the course of an outbreak","text":"substantial changes characteristics outbreak time — introduction therapeutics changing case definition. want estimate disease severity form case fatality risk (CFR) changes time correcting delay reporting outcomes cases.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"what-we-have","dir":"Articles","previous_headings":"","what":"What we have","title":"Estimating how disease severity varies over the course of an outbreak","text":"time-series cases deaths, (cases may substituted another indicator infections time); Data distribution delays, describing probability individual die tt days initially infected.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"potential-reasons-for-changing-disease-severity","dir":"Articles","previous_headings":"","what":"Potential reasons for changing disease severity","title":"Estimating how disease severity varies over the course of an outbreak","text":"Change probability infection reported case, Transmission dynamics within specific subgroups differing risk severe outcomes, Introduction vaccines therapeutics reducing relative risk death, Emergence pathogen variants may alter mortality risk associated infection.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"changing-severity-of-the-covid-19-pandemic-in-the-u-k-","dir":"Articles","previous_headings":"","what":"Changing severity of the Covid-19 pandemic in the U.K.","title":"Estimating how disease severity varies over the course of an outbreak","text":"example shows time-varying severity estimation using cfr data Covid-19 pandemic United Kingdom.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"preparing-the-raw-data","dir":"Articles","previous_headings":"Changing severity of the Covid-19 pandemic in the U.K.","what":"Preparing the raw data","title":"Estimating how disease severity varies over the course of an outbreak","text":"load example Covid-19 daily case death data provided cfr package covid_data, subset first year U.K. data. expect estimated CFR change period due changes pandemic response policy, changes case definitions, implementation relaxation lockdowns, new variants emerging.","code":"# get Covid data loaded with the package data(\"covid_data\") # filter for the U.K df_covid_uk <- filter( covid_data, country == \"United Kingdom\", date <= \"2020-12-31\" ) # View the first few rows and recall necessary columns: date, cases, deaths head(df_covid_uk) #> date country cases deaths #> 1 2020-01-03 United Kingdom 0 0 #> 2 2020-01-04 United Kingdom 0 0 #> 3 2020-01-05 United Kingdom 0 0 #> 4 2020-01-06 United Kingdom 0 0 #> 5 2020-01-07 United Kingdom 0 0 #> 6 2020-01-08 United Kingdom 0 0"},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"onset-to-death-distribution-for-covid-19","dir":"Articles","previous_headings":"Changing severity of the Covid-19 pandemic in the U.K.","what":"Onset-to-death distribution for Covid-19","title":"Estimating how disease severity varies over the course of an outbreak","text":"retrieve appropriate distribution duration symptom onset deaths reported Linton et al. (2020); lognormal distribution μ\\mu = 2.577 σ\\sigma = 0.440. Linton et al. (2020) fitted discrete lognormal distribution — use continuous distribution . See vignette delay distributions using continuous instead discrete distribution acceptable, using discrete distributions cfr. Note also use central estimates distribution parameter, ignoring uncertainty parameters uncertainty resulting CFR likely underestimated.","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"estimating-the-naive-and-corrected-cfr","dir":"Articles","previous_headings":"Changing severity of the Covid-19 pandemic in the U.K.","what":"Estimating the naive and corrected CFR","title":"Estimating how disease severity varies over the course of an outbreak","text":"use cfr_time_varying() function within cfr package calculate time-varying CFR Covid-19 pandemic U.K., plot results. burn_in time used determine many days start outbreak excluded CFR calculation, potentially due poor data quality beginning outbreak. default value 7, ignores first week data. smoothing_window used smooth case death data using rolling median window corresponding size (days) using stats::runmed() internally — disabled default. Users apply smoothing reporting artefacts lower reporting weekends. Example plot naive time-varying CFR. calculate time-varying CFR Covid-19 pandemic U.K., uncorrected delays. red line shows CFR estimate shaded grey region shows lower upper limits estimate 95% confidence intervals. Note severity estimates confidence intervals cfr_time_varying() obtained Binomial test deaths (treated ‘successes’) estimated outcomes cases (depending whether delay correction applied; treated ‘trials’).","code":"# calculating the naive time-varying CFR df_covid_cfr_uk_naive <- cfr_time_varying( df_covid_uk, burn_in = 7, smoothing_window = 7 ) # calculating the corrected time-varying CFR df_covid_cfr_uk_corrected <- cfr_time_varying( df_covid_uk, delay_density = function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440), burn_in = 7, smoothing_window = 7 ) # assign method tag and plot df_covid_cfr_uk_naive$method <- \"naive\" df_covid_cfr_uk_corrected$method <- \"corrected\" df_covid_cfr_uk <- bind_rows(df_covid_cfr_uk_naive, df_covid_cfr_uk_corrected) ggplot(df_covid_cfr_uk) + geom_ribbon( aes( x = date, ymin = severity_low, ymax = severity_high, fill = method ), alpha = 0.5 ) + geom_line( aes( x = date, y = severity_estimate, colour = method ) ) + scale_x_date( date_labels = \"%b-%Y\" ) + scale_y_continuous( labels = percent ) + scale_fill_brewer( palette = \"Dark2\", name = NULL, labels = c(\"Naive CFR\", \"Corrected CFR\") ) + scale_colour_brewer( palette = \"Dark2\", name = NULL, labels = c(\"Naive CFR\", \"Corrected CFR\") ) + labs( x = \"Date\", y = \"CFR (%)\" ) + coord_cartesian( expand = FALSE ) + theme_classic() + theme(legend.position = \"top\") #> Warning: Removed 93 rows containing missing values or values outside the scale range #> (`geom_line()`)."},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"severity-of-covid-19-in-multiple-countries","dir":"Articles","previous_headings":"","what":"Severity of Covid-19 in multiple countries","title":"Estimating how disease severity varies over the course of an outbreak","text":"cfr_time_varying() cfr functions can conveniently applied nested data estimate time-varying severity Covid-19. refer user book R Data Science better explanation code used , including packages Tidyverse. use example Covid-19 cases deaths data provided package covid_data, excluding four countries provide weekly data (zeros dates ). simplicity, use delay distribution onset death countries — users note likely introduces biases given inter-country differences testing reporting policies. Finally plot time-varying CFR selection three countries large outbreaks Covid-19: Brazil, India, United States. Example plot corrected time-varying CFR. calculate time-varying CFR Covid-19 pandemic Brazil, India, United States, corrected delays.","code":"# countries with weekly reporting weekly_reporting <- c(\"France\", \"Germany\", \"Spain\", \"Ukraine\") covid_data <- filter(covid_data, !country %in% weekly_reporting) # for each country, get the time-varying severity estimate, # correcting for delays and smoothing the case and death data # first nest the data; nest() from {tidyr} df_covid_cfr <- nest( covid_data, .by = country ) # define delay density function delay_density <- function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440) # to each nested data frame, apply the function `cfr_time_varying` # overwrite the `data` column, as all data will be preserved df_covid_cfr <- mutate( df_covid_cfr, # using map() from {purrr} data = map( .x = data, .f = cfr_time_varying, # arguments to the function delay_density = delay_density, smoothing_window = 7, burn_in = 7 ) ) # unnest the cfr data; unnest() from {tidyr} df_covid_cfr <- unnest(df_covid_cfr, cols = data) filter(df_covid_cfr, country %in% c(\"Brazil\", \"India\", \"United States\")) %>% ggplot() + geom_ribbon( aes( x = date, ymin = severity_low, ymax = severity_high, group = country ), fill = \"grey\" ) + geom_line( aes( x = date, y = severity_estimate, colour = country ) ) + scale_x_date( date_labels = \"%b-%Y\" ) + scale_y_continuous( labels = percent ) + scale_colour_brewer( palette = \"Dark2\" ) + labs( x = \"Date\", y = \"CFR (%)\" ) + coord_cartesian( ylim = c(0, 0.15), expand = FALSE ) + theme_classic() + theme(legend.position = \"top\") #> Warning: Removed 215 rows containing missing values or values outside the scale range #> (`geom_line()`)."},{"path":"https://epiverse-trace.github.io/cfr/articles/estimate_time_varying_severity.html","id":"details-adjusting-for-delays-between-two-time-series","dir":"Articles","previous_headings":"","what":"Details: Adjusting for delays between two time series","title":"Estimating how disease severity varies over the course of an outbreak","text":"cfr_time_varying() estimates number cases known outcome time following Nishiura et al. (2009), calculating quantity ktk_t day within input data, represents number cases known adverse outcome (usually death), day tt. kt=∑j=0tctfj−t. k_t = \\sum_{j = 0}^t c_t f_{j - t}. assume severity measure (usually CFR) binomially distributed following way $$ d_t \\sim {\\sf Binomial}(k_t, \\theta_t). $$ use maximum likelihood estimation determine value θt\\theta_t tt, θ\\theta represents severity measure interest. precise severity measure — case fatality risk (CFR), infection fatality risk (IFR), hospitalisation fatality risk (HFR), etc. — θ\\theta represents depends upon input data given user. Note function arguments burn_in smoothing_window explicitly used calculation. burn_in controls many estimates beginning outbreak replaced NAs — calculation applied first burn_in data points. calculation applied smoothed data, smoothing_window specified.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/articles/software-permissions.html","id":"scope-of-regulations","dir":"Articles","previous_headings":"","what":"Scope of regulations","title":"Software permissions and regulations","text":"package Software Medical Device (SaMD).","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/software-permissions.html","id":"data-privacy-and-integrity","dir":"Articles","previous_headings":"","what":"Data privacy and integrity","title":"Software permissions and regulations","text":"package read data user computer package write data user computer package interact external peripherals connected user computer (, limited : microphone, webcam, printer, etc.)","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/software-permissions.html","id":"internet-access","dir":"Articles","previous_headings":"","what":"Internet access","title":"Software permissions and regulations","text":"package download data internet package upload data internet package CAN used offline","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/software-permissions.html","id":"registration-and-third-parties","dir":"Articles","previous_headings":"","what":"Registration and third parties","title":"Software permissions and regulations","text":"Usage package require registration Usage package involve third-party services Usage package restricted certain geographical regions","code":""},{"path":"https://epiverse-trace.github.io/cfr/articles/software-permissions.html","id":"updates","dir":"Articles","previous_headings":"","what":"Updates","title":"Software permissions and regulations","text":"package automatically updated. Note means security updates automatically applied.","code":""},{"path":"https://epiverse-trace.github.io/cfr/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Pratik R. Gupte. Author, copyright holder. Adam Kucharski. Author, copyright holder, maintainer. Tim Russell. Author, copyright holder. Joshua W. Lambert. Reviewer. Hugo Gruson. Reviewer. Tim Taylor. Reviewer. James M. Azam. Reviewer. Abdoelnaser M. Degoot. Reviewer. Sebastian Funk. Reviewer.","code":""},{"path":"https://epiverse-trace.github.io/cfr/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Gupte P, Kucharski , Russell T (2024). cfr: Estimate Disease Severity Case Ascertainment. R package version 0.1.3, https://epiverse-trace.github.io/cfr/, https://github.com/epiverse-trace/cfr.","code":"@Manual{, title = {cfr: Estimate Disease Severity and Case Ascertainment}, author = {Pratik R. Gupte and Adam Kucharski and Tim Russell}, year = {2024}, note = {R package version 0.1.3, https://epiverse-trace.github.io/cfr/}, url = {https://github.com/epiverse-trace/cfr}, }"},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"cfr-estimate-disease-severity-and-under-reporting-","dir":"","previous_headings":"","what":"Estimate Disease Severity and Case Ascertainment","title":"Estimate Disease Severity and Case Ascertainment","text":"cfr R package estimate disease severity -reporting real-time, accounting delays epidemic time-series. cfr provides simple, fast methods calculate overall static case fatality risk (CFR) outbreak given time point, well CFR changes course outbreak. cfr can help estimate disease -reporting real-time, accounting delays reporting outcomes cases. cfr implements methods outlined Nishiura et al. (2009). plans add estimates based methods. cfr developed Centre Mathematical Modelling Infectious Diseases London School Hygiene Tropical Medicine part Epiverse-TRACE initiative.","code":""},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Estimate Disease Severity and Case Ascertainment","text":"cfr can installed CRAN using current development version cfr can installed GitHub using pak package.","code":"install.packages(\"cfr\") if(!require(\"pak\")) install.packages(\"pak\") pak::pak(\"epiverse-trace/cfr\")"},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"overall-severity-of-the-1976-ebola-outbreak","dir":"","previous_headings":"Quick start","what":"Overall severity of the 1976 Ebola outbreak","title":"Estimate Disease Severity and Case Ascertainment","text":"example shows use cfr estimate overall case fatality risks 1976 Ebola outbreak (Camacho et al. 2014), correcting delays using Gamma-distributed onset death duration taken Barry et al. (2018), shape kk 2.40 scale θ\\theta 3.33.","code":"# Load package library(cfr) # Load the Ebola 1976 data provided with the package data(ebola1976) # Focus on the first 20 days the outbreak ebola1976_first_30 <- ebola1976[1:30, ] # Calculate the static CFR without correcting for delays cfr_static(data = ebola1976_first_30) #> severity_estimate severity_low severity_high #> 1 0.4740741 0.3875497 0.5617606 # Calculate the static CFR while correcting for delays cfr_static( data = ebola1976_first_30, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) #> severity_estimate severity_low severity_high #> 1 0.9422 0.8701 0.9819"},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"change-in-real-time-estimates-of-overall-severity-during-the-1976-ebola-outbreak","dir":"","previous_headings":"Quick start","what":"Change in real-time estimates of overall severity during the 1976 Ebola outbreak","title":"Estimate Disease Severity and Case Ascertainment","text":"example show estimate overall severity can change data cases deaths time becomes available, using function cfr_rolling(). delay onset--death, simple “naive” calculation just divides deaths--date cases--date underestimate severity. cfr_rolling() function uses estimate_severity() adjustment internally account delays, instead compares deaths--date cases--known-outcome--date. adjusted estimate converges naive estimate outbreak declines larger proportion cases known outcomes. plot rolling CFR visualise severity changes time, using ggplot2 package. plotting code hidden . Disease severity ebola 1976 outbreak estimated day epidemic. rolling CFR value converges static value towards end outbreak. corrected uncorrected estimates shown.","code":"# Calculate the CFR without correcting for delays on each day of the outbreak rolling_cfr_naive <- cfr_rolling( data = ebola1976 ) # see the first few rows head(rolling_cfr_naive) #> date severity_estimate severity_low severity_high #> 1 1976-08-25 0 0 0.975 #> 2 1976-08-26 0 0 0.975 #> 3 1976-08-27 0 0 0.975 #> 4 1976-08-28 0 0 0.975 #> 5 1976-08-29 0 0 0.975 #> 6 1976-08-30 0 0 0.975 # Calculate the rolling daily CFR while correcting for delays rolling_cfr_corrected <- cfr_rolling( data = ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) head(rolling_cfr_corrected) #> date severity_estimate severity_low severity_high #> 1 1976-08-25 NA NA NA #> 2 1976-08-26 1e-04 1e-04 0.9999 #> 3 1976-08-27 1e-04 1e-04 0.9999 #> 4 1976-08-28 1e-04 1e-04 0.9999 #> 5 1976-08-29 1e-04 1e-04 0.9990 #> 6 1976-08-30 1e-04 1e-04 0.9942 # combine the data for plotting rolling_cfr_naive$method <- \"naive\" rolling_cfr_corrected$method <- \"corrected\" data_cfr <- rbind( rolling_cfr_naive, rolling_cfr_corrected )"},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"package-vignettes","dir":"","previous_headings":"","what":"Package vignettes","title":"Estimate Disease Severity and Case Ascertainment","text":"details use cfr can found online documentation package vignettes, “Articles”.","code":""},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"help","dir":"","previous_headings":"","what":"Help","title":"Estimate Disease Severity and Case Ascertainment","text":"report bug please open issue.","code":""},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"contribute","dir":"","previous_headings":"","what":"Contribute","title":"Estimate Disease Severity and Case Ascertainment","text":"Contributions cfr welcomed. Please follow package contributing guide.","code":""},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of conduct","title":"Estimate Disease Severity and Case Ascertainment","text":"Please note cfr project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"https://epiverse-trace.github.io/cfr/index.html","id":"related-projects","dir":"","previous_headings":"","what":"Related projects","title":"Estimate Disease Severity and Case Ascertainment","text":"cfr functionality overlaps packages, including coarseDataTools R package allows estimation relative case fatality risk covariate groups accounting delays due survival time, numbers deaths recoveries time known. cfr uses simpler methods Nishiura et al. (2009) can applied cases deaths time known, generating estimates based data date, well time-varying estimates. cfr can also convert estimates cases known outcomes time estimate -ascertainment, baseline estimate fatality risk available literature (e.g. past outbreaks). EpiNow2 R package can allow estimation case fatality risk defined secondary observation cases. particular, allows estimation accounts smooth underlying epidemic process, requires additional computational effort. comparison methods planned future release. cfr future expected benefit functionality forthcoming epiparameter package, also developed Epiverse-TRACE. epiparameter aims provide library epidemiological parameters parameterise delay density functions, well convenient class store, access, pass parameters delay correction.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr-package.html","id":null,"dir":"Reference","previous_headings":"","what":"cfr: Estimate Disease Severity and Case Ascertainment — cfr-package","title":"cfr: Estimate Disease Severity and Case Ascertainment — cfr-package","text":"Estimate severity disease ascertainment cases, discussed Nishiura et al. (2009) doi:10.1371/journal.pone.0006852 .","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"cfr: Estimate Disease Severity and Case Ascertainment — cfr-package","text":"Maintainer: Adam Kucharski adam.kucharski@lshtm.ac.uk (ORCID) [copyright holder] Authors: Pratik R. Gupte pratik.gupte@lshtm.ac.uk (ORCID) [copyright holder] Tim Russell timothy.russell@lshtm.ac.uk (ORCID) [copyright holder] contributors: Joshua W. Lambert joshua.lambert@lshtm.ac.uk (ORCID) [reviewer] Hugo Gruson hugo.gruson@data.org (ORCID) [reviewer] Tim Taylor tim.taylor@hiddenelephants.co.uk (ORCID) [reviewer] James M. Azam james.azam@lshtm.ac.uk (ORCID) [reviewer] Abdoelnaser M. Degoot abdoelnaser-mahmood.degoot@lshtm.ac.uk (ORCID) [reviewer] Sebastian Funk sebastian.funk@lshtm.ac.uk (ORCID) [reviewer]","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_rolling.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate static severity for an expanding time series — cfr_rolling","title":"Estimate static severity for an expanding time series — cfr_rolling","text":"Calculates CFR time point case death time series supplied, using expanding window time. static CFR calculated time point, using time series start time point, increasing number time points included one iteration.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_rolling.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate static severity for an expanding time series — cfr_rolling","text":"","code":"cfr_rolling(data, delay_density = NULL, poisson_threshold = 100)"},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_rolling.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate static severity for an expanding time series — cfr_rolling","text":"data containing outbreak data. daily time series dates absolute indicator time (e.g. epiday epiweek) numbers new cases new deaths time point. Note required columns \"date\" (date), \"cases\" (number reported cases), \"deaths\" (number reported deaths) day outbreak. Note required unbroken sequence dates missing dates . \"date\" column must class Date (see .Date()). Note also total number cases must greater total number reported deaths. delay_density optional argument controls whether delay correction applied severity estimation. May NULL, delay correction, function returns density function distribution evaluate density user-specified values, e.g. function(x) stats::dgamma(x = x, shape = 5, scale = 1). poisson_threshold case count use Poisson approximation. Set 100 default. Must > 0.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_rolling.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate static severity for an expanding time series — cfr_rolling","text":" date, maximum likelihood estimate 95% confidence interval daily severity estimates, named \"severity_estimate\", \"severity_low\", \"severity_high\", one row day original data.frame.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_rolling.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Estimate static severity for an expanding time series — cfr_rolling","text":"delay correction applied passing delay distribution density function delay_density, internal function .estimate_severity() used calculate rolling severity. Note naive method severity estimate confidence intervals calculated days cumulative number cases since start time-series, days cumulative number deaths reported exceeds cumulative reported cases, returned NA. cfr_rolling() applies internal function .estimate_severity() expanding time-series total cases, total estimated outcomes, total deaths. method used generate profile likelihood day depends outbreak size initial severity estimate day. essentially running cfr_static() new day. method used day communicated user, order prevent cluttering terminal messages.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_rolling.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate static severity for an expanding time series — cfr_rolling","text":"","code":"# load package data data(\"ebola1976\") # estimate severity without correcting for delays cfr_static(ebola1976) #> severity_estimate severity_low severity_high #> 1 0.955102 0.9210866 0.9773771 # estimate severity for each day while correcting for delays # obtain onset-to-death delay distribution parameters from Barry et al. 2018 # The Lancet. # view only the first values estimate <- cfr_rolling( ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) #> `cfr_rolling()` is a convenience function to help understand how additional data influences the overall (static) severity. Use `cfr_time_varying()` instead to estimate severity changes over the course of the outbreak. #> Some daily ratios of total deaths to total cases with known outcome are below 0.01%: some CFR estimates may be unreliable.FALSE head(estimate) #> date severity_estimate severity_low severity_high #> 1 1976-08-25 NA NA NA #> 2 1976-08-26 1e-04 1e-04 0.9999 #> 3 1976-08-27 1e-04 1e-04 0.9999 #> 4 1976-08-28 1e-04 1e-04 0.9999 #> 5 1976-08-29 1e-04 1e-04 0.9990 #> 6 1976-08-30 1e-04 1e-04 0.9942"},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate a static disease severity measure — cfr_static","title":"Estimate a static disease severity measure — cfr_static","text":"Calculates severity disease, optionally correcting reporting delays using epidemiological delay distribution time symptom onset death (onset--death). delay distributions may passed calculate different disease severity measures hospitalisation fatality risk.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate a static disease severity measure — cfr_static","text":"","code":"cfr_static(data, delay_density = NULL, poisson_threshold = 100)"},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate a static disease severity measure — cfr_static","text":"data containing outbreak data. daily time series dates absolute indicator time (e.g. epiday epiweek) numbers new cases new deaths time point. Note required columns \"date\" (date), \"cases\" (number reported cases), \"deaths\" (number reported deaths) day outbreak. Note required unbroken sequence dates missing dates . \"date\" column must class Date (see .Date()). Note also total number cases must greater total number reported deaths. delay_density optional argument controls whether delay correction applied severity estimation. May NULL, delay correction, function returns density function distribution evaluate density user-specified values, e.g. function(x) stats::dgamma(x = x, shape = 5, scale = 1). poisson_threshold case count use Poisson approximation. Set 100 default. Must > 0.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate a static disease severity measure — cfr_static","text":" maximum likelihood estimate 95% confidence interval severity estimates, named \"severity_estimate\", \"severity_low\", \"severity_high\".","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"details-adjusting-for-delays-between-two-time-series","dir":"Reference","previous_headings":"","what":"Details: Adjusting for delays between two time series","title":"Estimate a static disease severity measure — cfr_static","text":"method used cfr_static() follows Nishiura et al. (2009). function calculates quantity \\(u_t\\) day within input data, represents proportion cases estimated known outcome day \\(t\\). Following Nishiura et al., \\(u_t\\) calculated : $$u_t = \\dfrac{\\sum_{= 0}^t \\sum_{j = 0}^\\infty c_i f_{j - }}{\\sum_{= 0} c_i}$$ \\(f_t\\) value probability mass function time \\(t\\) \\(c_t\\), \\(d_t\\) number new cases new deaths time \\(t\\), (respectively). use \\(u_t\\) end outbreak following likelihood function estimate severity disease question. $${\\sf L}({\\theta \\mid y}) = \\log{\\dbinom{u_tC}{D}} + D \\log{\\theta} + (u_tC - D)\\log{(1.0 - \\theta)}$$ \\(C\\) \\(D\\) cumulative number cases deaths (respectively) time \\(t\\). \\(\\theta\\) parameter wish estimate, severity disease. estimate \\(\\theta\\) using simple maximum-likelihood methods, allowing functions within package quick easy tools use. precise severity measure — CFR, IFR, HFR, etc — \\(\\theta\\) represents depends upon input data given user. epidemiological delay-distribution density function passed delay_density used evaluate probability mass function parameterised time; .e. \\(f(t)\\) gives probability case known outcome (usually death) time \\(t\\), parameterised disease-specific parameters supplied .","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"profile-likelihood-methods","dir":"Reference","previous_headings":"","what":"Profile likelihood methods","title":"Estimate a static disease severity measure — cfr_static","text":"naive CFR estimate (without delay correction) outcome Binomial test deaths cases using stats::binom.test(). confidence intervals around estimate also taken test. delay-corrected CFR estimates however obtained generating profile likelihood sequence seq(1e-4, 1.0, 1e-4). method used depends outbreak size initial expectation disease severity. implemented internal function .estimate_severity(). Delay correction, small outbreaks: outbreaks total cases user-specified 'Poisson threshold' (poisson_threshold, default = 100), CFR uncertainty around taken profile likelihood generated Binomial model deaths (successes) estimated known outcomes (trials). Delay correction, large outbreaks low severity: outbreaks total cases greater Poisson threshold (default = 100) initial severity estimates < 0.05, CFR uncertainty taken Poisson approximation Binomial profile likelihood (taking \\(\\lambda = np\\) \\(n\\) estimated outcomes \\(p\\) severity estimate). Delay correction, large outbreaks higher severity: outbreaks total cases greater Poisson threshold (default = 100) initial severity estimates \\(\\geq\\) 0.05, CFR uncertainty taken Normal approximation Binomial profile likelihood.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Estimate a static disease severity measure — cfr_static","text":"Nishiura, H., Klinkenberg, D., Roberts, M., & Heesterbeek, J. . P. (2009). Early Epidemiological Assessment Virulence Emerging Infectious Diseases: Case Study Influenza Pandemic. PLOS ONE, 4(8), e6852. doi:10.1371/journal.pone.0006852","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_static.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate a static disease severity measure — cfr_static","text":"","code":"# load package data data(\"ebola1976\") # estimate severity without correcting for delays cfr_static(ebola1976) #> severity_estimate severity_low severity_high #> 1 0.955102 0.9210866 0.9773771 # estimate severity for each day while correcting for delays # obtain onset-to-death delay distribution parameters from Barry et al. 2018 # The Lancet. cfr_static( ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) #> severity_estimate severity_low severity_high #> 1 0.9592 0.9295 0.9793"},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate a severity measure that varies over time — cfr_time_varying","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":"Calculates severity disease changes time optionally correcting reporting delays using epidemiological delay distribution time symptom onset outcome (e.g. onset--death fatality risk).","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":"","code":"cfr_time_varying( data, delay_density = NULL, burn_in = 7, smoothing_window = NULL )"},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":"data containing outbreak data. daily time series dates absolute indicator time (e.g. epiday epiweek) numbers new cases new deaths time point. Note required columns \"date\" (date), \"cases\" (number reported cases), \"deaths\" (number reported deaths) day outbreak. Note required unbroken sequence dates missing dates . \"date\" column must class Date (see .Date()). Note also total number cases must greater total number reported deaths. delay_density optional argument controls whether delay correction applied severity estimation. May NULL, delay correction, function returns density function distribution evaluate density user-specified values, e.g. function(x) stats::dgamma(x = x, shape = 5, scale = 1). burn_in single integer-like value number time-points (typically days) disregard start time-series, burn-period desired. Defaults 7, sensible default value disregards first week cases deaths, assuming daily data. consider case data including start time-series, set argument 0. smoothing_window odd number determining smoothing window size use smoothing case death time-series, using rolling median procedure (k argument stats::runmed()) calculating time-varying severity. default behaviour apply smoothing. minimum value argument 1.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":" date, maximum likelihood estimate 95% confidence interval daily severity estimates, named \"severity_estimate\", \"severity_low\", \"severity_high\", one row day original data.frame.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":"details-adjusting-for-delays-between-two-time-series","dir":"Reference","previous_headings":"","what":"Details: Adjusting for delays between two time series","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":"function estimates number cases known outcome time, following Nishiura et al. (2009). function calculates quantity \\(k_t\\) day within input data, represents number cases estimated known outcome, day \\(t\\). \\(k_t\\) calculated following way: $$k_t = \\sum_{j = 0}^t c_t f_{j - t}$$ assume severity measure, example CFR, interest binomially distributed, following way: $$d_t \\sim {\\sf Binomial}(k_t, \\theta_t)$$ use maximum likelihood estimation determine value \\(\\theta_t\\) \\(t\\), \\(\\theta\\) represents severity measure interest. epidemiological delay distribution passed delay_density used obtain probability mass function parameterised time; .e. \\(f(t)\\) gives probability binary outcome case (survival death) known time \\(t\\). delay distribution parameterised disease-specific parameters supplied . Note function arguments burn_in smoothing_window explicitly used calculation. burn_in controls many estimates beginning outbreak replaced NAs — calculation applied first burn_in data points. calculation applied smoothed data, smoothing_window specified.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":"Nishiura, H., Klinkenberg, D., Roberts, M., & Heesterbeek, J. . P. (2009). Early Epidemiological Assessment Virulence Emerging Infectious Diseases: Case Study Influenza Pandemic. PLOS ONE, 4(8), e6852. doi:10.1371/journal.pone.0006852","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/cfr_time_varying.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate a severity measure that varies over time — cfr_time_varying","text":"","code":"# get data pre-loaded with the package data(\"covid_data\") df_covid_uk <- covid_data[covid_data$country == \"United Kingdom\" & covid_data$date <= as.Date(\"2020-09-01\"), ] # estimate time varying severity without correcting for delays cfr_time_varying <- cfr_time_varying( data = df_covid_uk, burn_in = 7L ) # View tail(cfr_time_varying) #> date severity_estimate severity_low severity_high #> 238 2020-08-27 0.017322835 0.010887155 0.02611008 #> 239 2020-08-28 0.011527378 0.006602850 0.01865240 #> 240 2020-08-29 0.007542426 0.003903177 0.01313800 #> 241 2020-08-30 0.007352941 0.003804975 0.01280885 #> 242 2020-08-31 0.006504065 0.002812052 0.01277518 #> 243 2020-09-01 0.009393681 0.004698353 0.01674560 # estimate time varying severity while correcting for delays # obtain onset-to-death delay distribution parameters from Linton et al. 2020 # J. Clinical Medicine: # view only the first values cfr_time_varying <- cfr_time_varying( data = df_covid_uk, delay_density = function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440), burn_in = 7L ) tail(cfr_time_varying) #> date severity_estimate severity_low severity_high #> 238 2020-08-27 0.021317829 0.013406829 0.03209837 #> 239 2020-08-28 0.015281757 0.008759411 0.02469826 #> 240 2020-08-29 0.011310085 0.005857363 0.01967302 #> 241 2020-08-30 0.011204482 0.005802549 0.01949011 #> 242 2020-08-31 0.007407407 0.003203259 0.01454312 #> 243 2020-09-01 0.010110294 0.005057522 0.01801795"},{"path":"https://epiverse-trace.github.io/cfr/reference/covid_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Daily Covid-19 case and death data for countries with 100,000 or more deaths — covid_data","title":"Daily Covid-19 case and death data for countries with 100,000 or more deaths — covid_data","text":"Data adapted {covidregionaldata} package daily cases deaths 19 countries 100,000 deaths period 2020-01-01 2022-12-31. See References publication links data sources made available {covidregionaldata}. Included {covidregionaldata} longer CRAN. Data provided .","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/covid_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Daily Covid-19 case and death data for countries with 100,000 or more deaths — covid_data","text":"","code":"covid_data"},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/reference/covid_data.html","id":"covid-data","dir":"Reference","previous_headings":"","what":"covid_data","title":"Daily Covid-19 case and death data for countries with 100,000 or more deaths — covid_data","text":" 20,786 rows 4 columns: date Calendar date format %Y-%m-%d country country name simple format, e.g. \"United States\" rather \"United States America\" cases Number cases reported date deaths Number deaths reported date","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/covid_data.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Daily Covid-19 case and death data for countries with 100,000 or more deaths — covid_data","text":"doi:10.21105/joss.03290 .","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/covid_data.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Daily Covid-19 case and death data for countries with 100,000 or more deaths — covid_data","text":"Joseph Palmer, Katharine Sherratt, Richard Martin-Nielsen, Jonnie Bevan, Hamish Gibbs, Sebastian Funk Sam Abbott (2021). covidregionaldata: Subnational data COVID-19 epidemiology. doi:10.21105/joss.03290","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/delay_density_helpers.html","id":null,"dir":"Reference","previous_headings":"","what":"Check delay density functions passed to exported functions — delay_density_helpers","title":"Check delay density functions passed to exported functions — delay_density_helpers","text":"Internal helper function check whether function passed delay_density argument cfr_*() estimate_outcomes() meet requirements package methods. test_fn_req_args() checks whether function expected number required arguments, .e., arguments without default values. Defaults checking single required argument. test_fn_num_out() checks whether function returns numeric output consistent evaluating probability density probability mass function distribution sequence values. Expects function returns numeric vector finite values \\(\\geq\\) 0.0, values missing, output vector length input vector.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/delay_density_helpers.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check delay density functions passed to exported functions — delay_density_helpers","text":"","code":"test_fn_req_args(fn, n_req_args = 1) test_fn_num_out(fn, n = 10)"},{"path":"https://epiverse-trace.github.io/cfr/reference/delay_density_helpers.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check delay density functions passed to exported functions — delay_density_helpers","text":"fn function. expected function evaluating density distribution numeric values, suitable passed delay_density cfr_*(). n_req_args number required arguments, .e., arguments without default values. n number elements evaluate function fn. Defaults 10, fn evaluated seq(n).","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/delay_density_helpers.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check delay density functions passed to exported functions — delay_density_helpers","text":"logical whether function fn fulfils conditions specified respective checks.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-estimate_severity.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate the corrected case fatality risk — .estimate_severity","title":"Estimate the corrected case fatality risk — .estimate_severity","text":"Estimates maximum likelihood estimate 95% confidence interval corrected severity, using total cases total cases known outcomes, latter replaces total number deaths standard (naive) severity definition. use binomial likelihood, approximated Poisson likelihood large samples.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-estimate_severity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate the corrected case fatality risk — .estimate_severity","text":"","code":".estimate_severity( total_cases, total_deaths, total_outcomes, poisson_threshold, p_mid = total_deaths/round(total_outcomes) )"},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-estimate_severity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate the corrected case fatality risk — .estimate_severity","text":"total_cases total number cases observed period outbreak interest. total number cases must greater equal total number deaths. total_deaths total number deaths observed period outbreak interest. total number deaths must less equal total number cases. total_outcomes total number outcomes expected observed period outbreak interest. See estimate_outcomes(). poisson_threshold case count use Poisson approximation. Set 100 default. Must > 0. p_mid initial severity estimate, used determine likelihood approximation used total_cases > poisson_threshold. Defaults total_deaths / round(total_outcomes).","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-estimate_severity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate the corrected case fatality risk — .estimate_severity","text":" one row three columns maximum likelihood estimate 95% confidence interval corrected severity estimates, named \"severity_estimate\", \"severity_low\", \"severity_high\".","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-estimate_severity.html","id":"special-cases","dir":"Reference","previous_headings":"","what":"Special cases","title":"Estimate the corrected case fatality risk — .estimate_severity","text":"two total_cases, total_deaths, total_outcomes 0, estimate confidence intervals calculated output contains NAs. total_outcomes <= total_deaths, estimate confidence intervals reliably calculated returned NA.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-select_func_likelihood.html","id":null,"dir":"Reference","previous_headings":"","what":"Select a likelihood function for severity estimation — .select_func_likelihood","title":"Select a likelihood function for severity estimation — .select_func_likelihood","text":"Switches Binomial, Poisson, Normal approximation based total number cases initial estimate severity.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-select_func_likelihood.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select a likelihood function for severity estimation — .select_func_likelihood","text":"","code":".select_func_likelihood(total_cases, poisson_threshold, p_mid)"},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-select_func_likelihood.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select a likelihood function for severity estimation — .select_func_likelihood","text":"total_cases single count total number cases outbreak. poisson_threshold single count threshold cases Poisson Normal approximation returned. p_mid single positive number bounded 0 – 1, representing initial estimate severity, used determine whether Poisson Normal approximation returned. determine whether","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-select_func_likelihood.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select a likelihood function for severity estimation — .select_func_likelihood","text":"function three arguments, total_outcomes, total_deaths, pp, used generate profile likelihood. Also prints messages screen Poisson Normal approximation function returned.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/dot-select_func_likelihood.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Select a likelihood function for severity estimation — .select_func_likelihood","text":"Returns likelihood function follows: Binomial approximation: total_cases < poisson_threshold, used cases, small outbreak; Poisson approximation: total_cases >= poisson_threshold p_mid < 0.05;","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/ebola1976.html","id":null,"dir":"Reference","previous_headings":"","what":"Ebola 1976 outbreak case data — ebola1976","title":"Ebola 1976 outbreak case data — ebola1976","text":"example epidemic outbreak dataset use cfr package. dataset comes first Ebola outbreak Zaire 1976 analysed Camacho et al. (2014).","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/ebola1976.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ebola 1976 outbreak case data — ebola1976","text":"","code":"ebola1976"},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/reference/ebola1976.html","id":"ebola-","dir":"Reference","previous_headings":"","what":"ebola1976","title":"Ebola 1976 outbreak case data — ebola1976","text":" 73 rows 3 columns: date Calendar date cases Number cases reported deaths Number deaths reported","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/ebola1976.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Ebola 1976 outbreak case data — ebola1976","text":"doi:10.1016/j.epidem.2014.09.003","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/ebola1976.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Ebola 1976 outbreak case data — ebola1976","text":"Camacho, ., Kucharski, . J., Funk, S., Breman, J., Piot, P., & Edmunds, W. J. (2014). Potential large outbreaks Ebola virus disease. Epidemics, 9, 70–78. doi:10.1016/j.epidem.2014.09.003","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_ascertainment.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","title":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","text":"Estimates proportion cases infections ascertained, given time-series cases deaths, delay distribution baseline severity estimate. resulting ascertainment estimate calculated ratio baseline severity estimate, assumed 'true' disease severity, delay-adjusted severity estimate.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_ascertainment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","text":"","code":"estimate_ascertainment(data, severity_baseline, delay_density = NULL)"},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_ascertainment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","text":"data containing outbreak data. daily time series dates absolute indicator time (e.g. epiday epiweek) numbers new cases new deaths time point. Note required columns \"date\" (date), \"cases\" (number reported cases), \"deaths\" (number reported deaths) day outbreak. Note required unbroken sequence dates missing dates . \"date\" column must class Date (see .Date()). Note also total number cases must greater total number reported deaths. severity_baseline single number range 0.0 – 1.0 assumed true baseline severity estimate used estimate overall ascertainment ratio. Missing default, causes function error; must supplied user. delay_density optional argument controls whether delay correction applied severity estimation. May NULL, delay correction, function returns density function distribution evaluate density user-specified values, e.g. function(x) stats::dgamma(x = x, shape = 5, scale = 1).","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_ascertainment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","text":" containing maximum likelihood estimate estimate 95% confidence interval corrected severity, named \"ascertainment_estimate\" (central estimate), \"ascertainment_low\" \"ascertainment_high\" lower upper interval limits.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_ascertainment.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","text":"estimate_ascertainment() uses cfr_static() internally obtain severity estimate compared user-specified baseline severity. profile likelihood method used obtain severity estimate decided internal function .estimate_severity() used cfr_static(), delay correction applied. See cfr_static() documentation explanation methods used depending outbreak size initial severity guess.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_ascertainment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate the ascertainment ratio of a disease — estimate_ascertainment","text":"","code":"# get data pre-loaded with the package data(\"covid_data\") df_covid_uk <- covid_data[covid_data$country == \"United Kingdom\", ] df_covid_uk_subset <- subset(df_covid_uk, date <= \"2020-05-31\") # use a severity baseline of 1.4% (0.014) taken from Verity et al. (2020) # Lancet Infectious Diseases: # use onset-to-death distribution from Linton et al. (2020) # J. Clinical Medicine: # subset data until 30th June 2020 data <- df_covid_uk[df_covid_uk$date <= \"2020-06-30\", ] estimate_ascertainment( data = data, delay_density = function(x) dlnorm(x, meanlog = 2.577, sdlog = 0.440), severity_baseline = 0.014 ) #> ascertainment_estimate ascertainment_low ascertainment_high #> 1 0.06779661 0.06734007 0.06829268"},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_outcomes.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","title":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","text":"Estimates expected number individuals known outcomes case outcome time series outbreak data, epidemiological delay distribution symptom onset outcome. calculating case fatality risk, outcomes must deaths, delay distribution must onset--death distribution, function returns estimates known death outcomes.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_outcomes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","text":"","code":"estimate_outcomes(data, delay_density)"},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_outcomes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","text":"data containing outbreak data. daily time series dates absolute indicator time (e.g. epiday epiweek) numbers new cases new deaths time point. Note required columns \"date\" (date), \"cases\" (number reported cases), \"deaths\" (number reported deaths) day outbreak. Note required unbroken sequence dates missing dates . \"date\" column must class Date (see .Date()). Note also total number cases must greater total number reported deaths. delay_density optional argument controls whether delay correction applied severity estimation. May NULL, delay correction, function returns density function distribution evaluate density user-specified values, e.g. function(x) stats::dgamma(x = x, shape = 5, scale = 1).","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_outcomes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","text":" columns data, two additional columns: \"estimated_outcomes\" number cases outcome interest (usually, death) estimated known dates specified data, u_t ratio cumulative number estimated known outcomes cumulative number cases reported date specified data.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_outcomes.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","text":"ratio u_t represents, outbreak, overall proportion cases whose outcomes expected known day $$. ongoing outbreak relatively long delays symptom onset case outcome, u_t value 1.0 may indicate outbreak ended, outcomes cases expected known.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/estimate_outcomes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate known outcomes of cases using a delay distribution — estimate_outcomes","text":"","code":"# Load Ebola 1976 outbreak data data(\"ebola1976\") # estimate severity for each day while correcting for delays # obtain onset-to-death delay distribution parameters from Barry et al. 2018 # examine the first few rows of the output estimated_outcomes <- estimate_outcomes( data = ebola1976, delay_density = function(x) dgamma(x, shape = 2.40, scale = 3.33) ) head(estimated_outcomes) #> date cases deaths estimated_outcomes u_t #> 1 1976-08-25 1 0 0.00000000 0.00000000 #> 2 1976-08-26 0 0 0.03323030 0.03323030 #> 3 1976-08-27 0 0 0.06494676 0.09817706 #> 4 1976-08-28 0 0 0.08485286 0.18302992 #> 5 1976-08-29 0 0 0.09400738 0.27703731 #> 6 1976-08-30 0 0 0.09515185 0.37218916"},{"path":"https://epiverse-trace.github.io/cfr/reference/prepare_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare common epidemiological data formats for CFR estimation — prepare_data","title":"Prepare common epidemiological data formats for CFR estimation — prepare_data","text":"S3 generic methods classes commonly used epidemiological data. Currently, supported data format incidence2 package. See incidence2::incidence(). Grouped data supported, see Details.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/prepare_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare common epidemiological data formats for CFR estimation — prepare_data","text":"","code":"prepare_data(data, ...) # S3 method for class 'incidence2' prepare_data( data, cases_variable = \"cases\", deaths_variable = \"deaths\", fill_NA = TRUE, ... )"},{"path":"https://epiverse-trace.github.io/cfr/reference/prepare_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare common epidemiological data formats for CFR estimation — prepare_data","text":"data -like object. Currently, objects supported. may grouped. ... Currently unused. Passing extra arguments throw warning. cases_variable string name cases variable \"count_variable\" column data. deaths_variable string name deaths variable \"count_variable\" column data. fill_NA logical indicating whether NAs cases deaths data replaced 0s. default value TRUE, message make users aware replacement.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/prepare_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare common epidemiological data formats for CFR estimation — prepare_data","text":" suitable disease severity estimation functions provided cfr, columns \"date\", \"cases\", \"deaths\". Additionally, grouped data, columns representing grouping variables also present. result continuous sequence dates start end date data; required data passed functions cfr_static().","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/prepare_data.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Prepare common epidemiological data formats for CFR estimation — prepare_data","text":"method data can replace NAs case death data 0s using fill_NA argument, TRUE default, meaning NAs replaced. Keeping NAs cause downstream issues calling functions cfr_static() data, handle NAs. Setting fill_NA = TRUE resolves issue. Passing grouped object data result function respecting grouping returning grouping variables separate columns.","code":""},{"path":"https://epiverse-trace.github.io/cfr/reference/prepare_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare common epidemiological data formats for CFR estimation — prepare_data","text":"","code":"#### For data #### # load Covid-19 data from incidence2 covid_uk <- incidence2::covidregionaldataUK # convert to incidence2 object covid_uk_incidence <- incidence2::incidence( covid_uk, date_index = \"date\", counts = c(\"cases_new\", \"deaths_new\"), count_names_to = \"count_variable\" ) #> Warning: `cases_new` contains NA values. Consider imputing these and calling `incidence()` again. # View tail of prepared data data <- prepare_data( covid_uk_incidence, cases_variable = \"cases_new\", deaths_variable = \"deaths_new\" ) #> NAs in cases and deaths are being replaced with 0s: Set `fill_NA = FALSE` to prevent this. tail(data) #> date cases deaths #> 485 2021-05-28 6205 6 #> 486 2021-05-29 5146 5 #> 487 2021-05-30 5395 8 #> 488 2021-05-31 6251 6 #> 489 2021-06-01 3346 4 #> 490 2021-06-02 0 0 #### For grouped data #### # convert data to incidence2 object grouped by region covid_uk_incidence <- incidence2::incidence( covid_uk, date_index = \"date\", counts = c(\"cases_new\", \"deaths_new\"), count_names_to = \"count_variable\", groups = \"region\" ) #> Warning: `cases_new` contains NA values. Consider imputing these and calling `incidence()` again. # View tail of prepared data data <- prepare_data( covid_uk_incidence, cases_variable = \"cases_new\", deaths_variable = \"deaths_new\" ) #> NAs in cases and deaths are being replaced with 0s: Set `fill_NA = FALSE` to prevent this. tail(data) #> date region cases deaths #> 6365 2021-06-02 Scotland 0 0 #> 6366 2021-06-02 South East 0 0 #> 6367 2021-06-02 South West 0 0 #> 6368 2021-06-02 Wales 0 0 #> 6369 2021-06-02 West Midlands 0 0 #> 6370 2021-06-02 Yorkshire and The Humber 0 0"},{"path":[]},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"cfr-013","dir":"Changelog","previous_headings":"","what":"cfr 0.1.3","title":"cfr 0.1.3","text":"Added vignette estimate_from_individual_data.Rmd describing relationship individual-level data aggregate estimation.","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"cfr-012","dir":"Changelog","previous_headings":"","what":"cfr 0.1.2","title":"cfr 0.1.2","text":"CRAN release: 2024-09-26 Updated version fix instability normal approximation displayed Ebola example. release includes: Removal normal approximation .estimate_severity() function, instead using binomial likelihood unless criteria Poisson approximation met. Updated README example focusing first 30 days outbreak, emphasise effects accounting delays outcome.","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"cfr-011","dir":"Changelog","previous_headings":"","what":"cfr 0.1.1","title":"cfr 0.1.1","text":"CRAN release: 2024-06-12 Maintainer changing @adamkucharski (#143).","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"major-changes-0-1-1","dir":"Changelog","previous_headings":"","what":"Major changes","title":"cfr 0.1.1","text":"output column names severity_mean ascertainment_mean corrected severity_estimate ascertainment_estimate. may break workflows rely previous column names (#146). version cfr includes changes severity estimation algorithms used calculating static severity measure, may lead small changes CFR values calculated using v0.1.0 (#129).","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"functions-0-1-1","dir":"Changelog","previous_headings":"","what":"Functions","title":"cfr 0.1.1","text":"cfr_static(): informative checks intermediate values passed .estimate_severity(). Prints message CFR value determined unreliable. cfr_rolling(): Prints message explaining convenience function. improved input checking. Uses new .estimate_severity() functionality based outbreak size initial expectation CFR (#129). Prints message rolling CFR values determined unreliable. .estimate_severity(): Renamed . prefix indicate internal function. Added parameter p_mid initial severity estimate, used determine likelihood approximation method. Selects among Binomial, Poisson, Normal approximation likelihood depending outbreak size p_mid using function .select_fun_likelihood(); prints message selected method (#129). Lowest possible severity estimate reduced 10−410^{-4}. Severity estimates confidence intervals stored named vectors rather . .select_func_likelihood(): Internal function added chooses likelihood approximation function based outbreak size p_mid. Binomial approximation used small outbreaks cumulative cases lower Poisson threshold. Poisson approximation used outbreaks Poisson threshold p_mid < 0.05. Normal approximation used outbreaks Poisson threshold p_mid > 0.05. test_fn_req_args() updated use Reduce(f = \"+\") Map() rather sum(mapply()).","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"documentation-0-1-1","dir":"Changelog","previous_headings":"","what":"Documentation","title":"cfr 0.1.1","text":"Added package level documentation. Updated Readme lifecycle (stable) RepoStatus (Active) badges (#113), added DPG badge (#127), updated related projects section; corrected figure labelling (#114). Updated _pkgdown.yaml manual Bootstrap version (#136) reference sections, added software permissions vignette (#125), enabled development mode (#143). Updated WORDLIST. Updated function documentation files (#134). Added section distributions vignette acceptable use continuous rather discrete distributions. Corrected explanation estimate_outcomes() static severity vignette added explanations profile likelihood generation methods used severity vignettes (#143). Corrected equations vignettes (#133) removed .estimate_severity() vignettes (#132).","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"tests-0-1-1","dir":"Changelog","previous_headings":"","what":"Tests","title":"cfr 0.1.1","text":"snapshots updated severity values new likelihood functions (#129). Added session global state checker script setup options script (#119). tests updated reflect functions sometimes throw informative messages. Tests using incidence2 suppress warnings missing values (added incidence2 v2.3.0) filling missing values subject test prepare_data.incidence2() (#143).","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"package-0-1-1","dir":"Changelog","previous_headings":"","what":"Package","title":"cfr 0.1.1","text":"Added updated GitHub Actions workflows dependency changes, linting, updating citation file, updating license year (#119, #137, #142). Updated GHA workflows infrastructure files match latest versions epiverse-trace/packagetemplate (#119). Normalised DESCRIPTION file. Added tools/check.env epiverse-trace/packagetemplate suppress specific checks package size, Rd cross references, GNU Make requirement, non-ASCII strings (#142).","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"cfr-010","dir":"Changelog","previous_headings":"","what":"cfr 0.1.0","title":"cfr 0.1.0","text":"CRAN release: 2023-11-21 Initial CRAN submission cfr, R package estimate severity disease ascertainment cases correcting delays outcomes reported cases known. release includes: Functions overall severity outbreak, overall severity outbreak estimated expanding time series data, time-varying severity outbreak, function estimate number outcomes expected given number cases assuming user-specified distribution delays cases outcomes known, function estimate overall (static) ascertainment cases outbreak comparing relevant severity measures user-specified baseline severity, data preparation generic S3 method class incidence2 package, Example daily case death data 1976 Ebola Virus Disease outbreak reported Camacho et al. (2014). https://doi.org/10.1016/j.epidem.2014.09.003, Example daily case death data Covid-19 pandemic range 2020-01-01 2022-12-31 19 countries 100,00 deaths period, taken covidregionaldata package longer CRAN, Vignettes describing get started severity estimation, detailed workflows different kinds severity estimation, vignette working data incidence2 package, vignette working delay distributions, 100% code coverage, Workflows render vignettes README website.","code":""},{"path":"https://epiverse-trace.github.io/cfr/news/index.html","id":"correction-0-1-0","dir":"Changelog","previous_headings":"","what":"Correction","title":"cfr 0.1.0","text":"cfr v0.1.0 includes functionality static ascertainment calculations. functionality time-varying ascertainment expected included future versions, older implementation removed just prior release. news section cfr v0.1.0 updated reflect .","code":""}]