knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  message = FALSE,
  warning = FALSE,
  fig.path = "man/figures/README-",
  out.width = "100%"
)

{{ packagename }}: Estimate disease severity and under-reporting

Digital Public Good License: MIT ![R-CMD-check](https://github.com/{{ gh_repo }}/actions/workflows/R-CMD-check.yaml/badge.svg) ![Codecov test coverage](https://codecov.io/gh/{{ gh_repo }}/branch/main/graph/badge.svg) Lifecycle: stable Project Status: Active – The project has reached a stable, usable state and is being actively developed. ![CRAN status](https://www.r-pkg.org/badges/version/{{ packagename }})

{{ packagename }} is an R package to estimate disease severity and under-reporting in real-time, accounting for delays in epidemic time-series.

{{ packagename }} provides simple, fast methods to calculate the overall or static case fatality risk (CFR) of an outbreak up to a given time point, as well as how the CFR changes over the course of the outbreak. {{ packagename }} can help estimate disease under-reporting in real-time, accounting for delays reporting the outcomes of cases.

{{ packagename }} implements methods outlined in @nishiura2009. There are plans to add estimates based on other methods.

{{ packagename }} is developed at the Centre for the Mathematical Modelling of Infectious Diseases at the London School of Hygiene and Tropical Medicine as part of the Epiverse-TRACE initiative.

Installation

{{ packagename }} can be installed from CRAN using

install.packages("{{ packagename }}")

The current development version of {{ packagename }} can be installed from GitHub using the pak package.

if(!require("pak")) install.packages("pak")
pak::pak("{{ gh_repo }}")

Quick start

Overall severity of the 1976 Ebola outbreak

This example shows how to use {{ packagename }} to estimate the overall case fatality risks from the 1976 Ebola outbreak [@camacho2014], while correcting for delays using a Gamma-distributed onset to death duration taken from @barry2018, with a shape $k$ of 2.40 and a scale $\theta$ of 3.33.

# 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)

# 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)
)

Change in real-time estimates of overall severity during the 1976 Ebola outbreak

In this example we show how the estimate of overall severity can change as more data on cases and deaths over time becomes available, using the function cfr_rolling(). Because there is a delay from onset-to-death, a simple "naive" calculation that just divides deaths-to-date by cases-to-date will underestimate severity. The cfr_rolling() function uses the estimate_severity() adjustment internally to account for delays, and instead compares deaths-to-date with cases-with-known-outcome-to-date. The adjusted estimate converges to the naive estimate as the outbreak declines and a larger proportion of cases have known outcomes.

# 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)

# 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)

We plot the rolling CFR to visualise how severity changes over time, using the ggplot2 package. The plotting code is hidden here.

# combine the data for plotting
rolling_cfr_naive$method <- "naive"
rolling_cfr_corrected$method <- "corrected"

data_cfr <- rbind(
  rolling_cfr_naive,
  rolling_cfr_corrected
)
library(ggplot2)

# visualise both corrected and uncorrected rolling estimates
ggplot(data_cfr) +
  geom_ribbon(
    aes(
      date,
      ymin = severity_low, ymax = severity_high,
      fill = method
    ),
    alpha = 0.2, show.legend = FALSE
  ) +
  geom_line(
    aes(date, severity_estimate, colour = method)
  ) +
  scale_colour_brewer(
    palette = "Dark2",
    labels = c("Corrected CFR", "Naive CFR"),
    name = NULL
  ) +
  scale_fill_brewer(
    palette = "Dark2"
  ) +
  scale_x_date(
    date_labels = "%d-%b-%Y",
    name = "Date"
  ) +
  labs(
    y = "Disease severity"
  ) +
  theme_classic() +
  theme(legend.position = "top")

Package vignettes

More details on how to use {{ packagename }} can be found in the online documentation as package vignettes, under "Articles".

Help

To report a bug please open an issue.

Contribute

Contributions to {{ packagename }} are welcomed. Please follow the package contributing guide.

Code of conduct

Please note that the {{ packagename }} project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Related projects

cfr functionality overlaps with that of some other packages, including

cfr is in future expected to benefit from the functionality of the forthcoming epiparameter package, which is also developed by Epiverse-TRACE. epiparameter aims to provide a library of epidemiological parameters to parameterise delay density functions, as well as the convenient <epiparameter> class to store, access, and pass these parameters for delay correction.

References



epiverse-trace/datadelay documentation built on March 6, 2025, 12:55 a.m.