Prepare impact diagnostics for plotting
Source:R/fn_plotting_prep_impact_diagnostics.R
plot_prep_impact_diagnostics.RdA suite of helper functions that sit between impact diagnostics functions and plotting functions. These functions transform and aggregate impact estimates to prepare them for visualisation. Functions have basic checks on input data but otherwise assume users will not modify inputs.
Usage
prep_plot_mod_grp_varn(df2, df3, outcome = IMPACT_OUTCOMES)
prep_plot_vax_gavi(
data,
prev_data,
outcome = IMPACT_OUTCOMES,
touchstone_old = DEF_TOUCHSTONE_OLD,
touchstone_new = DEF_TOUCHSTONE_NEW
)
prep_plot_cumul(
data,
outcome,
disease,
touchstone_old = DEF_TOUCHSTONE_OLD,
touchstone_new = DEF_TOUCHSTONE_NEW
)Arguments
- df2
A
<tibble>of impact estimates with at least columnsmodelling_group,vaccine, outcome variable, andfvps(doses delivered). Used as the primary data source for calculations inprep_plot_mod_grp_varn().- df3
A
<tibble>of modelling group and vaccine combinations, typically with one row per modelling group per vaccine. Joined withdf2to ensure complete group coverage inprep_plot_mod_grp_varn().- outcome
A character string for the impact outcome. Must be one of
"deaths_averted"or"dalys_averted". Forprep_plot_cumul(),datamust include columns named{outcome}_oldand{outcome}_new.- data
A
<tibble>of impact estimates with columns including at least those in COLNAMES_KEY_PRESSURE_TEST, the outcome variable, and potentially other columns for analysis.- prev_data
A
<tibble>of impact estimates from a previous touchstone, used as a comparison baseline. Should have the same structure asdata.- touchstone_old
A six-character touchstone identifier (YYYYMM format) for the previous dataset. Defaults to DEF_TOUCHSTONE_OLD. Used in
prep_plot_vax_gavi()andprep_plot_cumul().- touchstone_new
A six-character touchstone identifier (YYYYMM format) for the current dataset. Defaults to DEF_TOUCHSTONE_NEW. Used in
prep_plot_vax_gavi()andprep_plot_cumul().- disease
A character string specifying a single disease for filtering and analysis.
Value
prep_plot_mod_grp_varn()returns a grouped<tibble>(grouped byvaccine) with all columns fromdf2anddf3plus derived columns:adj_outc(adjusted outcome with small offset),outcome_name(input outcome), andmean_outc(vaccine-level weighted mean outcome).prep_plot_vax_gavi()returns a<tibble>with columnsdisease,year,yearly_outcome,dataset(factor with levels for old touchstone, "Difference", and new touchstone), andoutcome_name. Summarizes outcomes by disease and year across two touchstones.prep_plot_cumul()returns a<tibble>with columnsyear,modelling_group,touchstone,value(cumulative or average outcome),line_type("solid" for individual models, "dashed" for model average), andoutcome_name. ReturnsNULLif the specified disease has no non-zero data to plot.