Calculate attack rate, case fatality rate, and mortality rate

attack_rate(
cases,
population,
conf_level = 0.95,
multiplier = 100,
mergeCI = FALSE,
digits = 2
)

case_fatality_rate(
deaths,
population,
conf_level = 0.95,
multiplier = 100,
mergeCI = FALSE,
digits = 2
)

case_fatality_rate_df(
x,
deaths,
group = NULL,
conf_level = 0.95,
multiplier = 100,
mergeCI = FALSE,
digits = 2,
)

mortality_rate(
deaths,
population,
conf_level = 0.95,
multiplier = 10^4,
mergeCI = FALSE,
digits = 2
)

## Arguments

cases, deaths number of cases or deaths in a population. For _df functions, this can be the name of a logical column OR an evaluated logical expression (see examples). the number of individuals in the population. a number representing the confidence level for which to calculate the confidence interval. Defaults to 0.95, representing a 95% confidence interval using binom::binom.wilson() The base by which to multiply the output: multiplier = 1: ratio between 0 and 1 multiplier = 100: proportion multiplier = 10^4: x per 10,000 people Whether or not to put the confidence intervals in one column (default is FALSE) if mergeCI = TRUE, this determines how many digits are printed a data frame the bare name of a column to use for stratifying the output if group is not NULL, then this will add a row containing the total value across all groups.

## Value

a data frame with five columns that represent the numerator, denominator, rate, lower bound, and upper bound.

• attack_rate(): cases, population, ar, lower, upper

• case_fatality_rate(): deaths, population, cfr, lower, upper

## Examples

# Attack rates can be calculated with just two numbers
print(ar <- attack_rate(10, 50), digits = 4) # 20% attack rate#>   cases population ar lower upper
#> 1    10         50 20 11.24 33.04
# print them inline using fmt_ci_df()
fmt_ci_df(ar)#> [1] "20.00% (CI 11.24--33.04)"
# Alternatively, if you want one column for the CI, use mergeCI = TRUE
attack_rate(10, 50, mergeCI = TRUE, digits = 2) # 20% attack rate#>   cases population ar             ci
#> 1    10         50 20 (11.24--33.04)
print(cfr <- case_fatality_rate(1, 100), digits = 2) # CFR of 1%#>   deaths population cfr lower upper
#> 1      1        100   1  0.18   5.4fmt_ci_df(cfr)#> [1] "1.00% (CI 0.18--5.45)"
# using a data frame
if (require("outbreaks")) {
withAutoprint({
e <- outbreaks::ebola_sim$linelist case_fatality_rate_df(e, outcome == "Death", group = gender, add_total = TRUE, mergeCI = TRUE ) }) }#> Loading required package: outbreaks#> > e <- outbreaks::ebola_sim$linelist
#> > case_fatality_rate_df(e, outcome == "Death", group = gender, add_total = TRUE,
#> +     mergeCI = TRUE)
#> # A tibble: 3 x 5
#>   gender deaths population   cfr ci
#>   <fct>   <int>      <int> <dbl> <chr>
#> 1 f        1301       2299  56.6 (54.55--58.60)
#> 2 m        1281       2266  56.5 (54.48--58.56)
#> 3 Total    2582       4565  56.6 (55.12--57.99)