
Plot Case Fatality Ratios, Total Cases, and Beta Distributions by Country
Source:R/plot_CFR_by_country.R
plot_CFR_by_country.RdThis function creates two separate plots: one for case fatality ratios (CFR) with confidence intervals and total cases by country, and another for Beta distributions for selected countries. The plots are generated based on cholera data stored in the PATHS$DATA_WHO_ANNUAL directory.
Arguments
- PATHS
A list containing the paths where the cholera data and figures will be saved. Typically generated by the
get_paths()function and should include:DATA_WHO_ANNUAL: Path to the directory where processed WHO annual cholera data is located.
DOCS_FIGURES: Path to the directory where the plots will be saved.
Value
Invisibly, a list of the two ggplot objects: cfr_and_cases
(CFR and total cases) and beta_distributions (Beta densities;
NULL when no density could be drawn). Each figure drawn is also
saved to PATHS$DOCS_FIGURES.
Details
The Beta densities (AFRO Region and the countries with the lowest and
highest CFR) are evaluated on an adaptive grid: a uniform grid of 1,000 points
over the plotted range plus 500 points across each density's central
99.98% interval, so a very narrow density is resolved (the AFRO Region Beta,
built from more than a million cases, has an SD of about 1e-4, ten times
narrower than the spacing of a uniform 1,000-point grid from 0 to 1). The x axis
runs from 0 to 1.1 times the largest 99.99% quantile of the plotted densities,
and the y axis is on a square-root scale so the tall AFRO density and the much
wider country densities are visible together. A density with
shape1 < 1 (a country with no recorded deaths) is unbounded at 0 and is
drawn from the first grid point above 0.
Examples
if (FALSE) { # \dontrun{
PATHS <- get_paths()
plot_CFR_by_country(PATHS)
} # }