Estimate vaccine-induced immunity levels from routine immunization data
Source:R/main.R
compute_immunity_sample.Rdcompute_immunity_sample(): Wrapper that estimates immunity for a single imputation sample from imputation through immunity estimation.compute_immunity_samples(): Performs the complete process for multiple imputation samples. The number of samples depends on your chosenimputation_mode:'deterministic': Fixed at 3 samples (minimum, mean, and maximum aggregations);'stochastic': User-specified via then_samplesargument;'custom': Specifyn_samplesif your custom function is stochastic; otherwise, all samples will yield identical results.
summarize_immunity_samples(): Aggregates immunity estimates across multiple samples (output ofcompute_immunity_samples()) by computing summary statistics including mean, median, quantiles, standard deviation, empirical quantiles, and t-based 95% confidence intervals for the mean.
Usage
compute_immunity_samples(
ri_data,
live_births = deprecated(),
vs_info,
efficacy,
neighbors,
...,
n_samples = 1,
birth_seasonality = NULL,
sample_pair = NULL,
imputation_mode = NULL,
sample_mode = NULL,
bandwidth = 1,
zero.rm = TRUE,
.sampler_args = rlang::list2(),
shift_mode = "full",
hed_assumption = NULL,
max_level = 1,
dd_assumption = NULL,
vax_imm_type = NULL,
rho = 0,
per_imm_type = TRUE,
quiet = TRUE,
seed = TRUE
)
compute_immunity_sample(
ri_data,
efficacy,
neighbors,
...,
doses_ratio = deprecated(),
vs_info = NULL,
birth_seasonality = NULL,
shift_prop = NULL,
sample_pair = NULL,
imputation_mode = NULL,
sample_mode = NULL,
bandwidth = 1,
zero.rm = TRUE,
.sampler_args = rlang::list2(),
shift_mode = "full",
hed_assumption = NULL,
max_level = 1,
dd_assumption = NULL,
vax_imm_type = NULL,
rho = 0,
per_imm_type = TRUE,
quiet = TRUE
)
summarize_immunity_samples(
immunity_samples,
...,
by_admin = NULL,
by_time = NULL
)Arguments
- ri_data
As defined in
impute_missing_doses().- live_births
[data.frame]Number of babies born in a given admin unit in a given year. This argument is deprecated as of version 0.2.0. Please include the live births data in the routine immunization data (
ri_data) instead with its column named according tobirthargument inconfig_pviem().- vs_info
[data.frame]The vaccination schedule table preprocessed withpreprocess_vs_info()which is structured as prep_dummy_vs_info. dummy_vs_info defines the structure of the raw format before preprocessing.- efficacy
[data.frame]Vaccine doses efficacy estimates table preprocessed withpreprocess_efficacy()which is structured as prep_dummy_efficacy. efficacy_default defines the structure of the raw format before preprocessing.- neighbors
As defined in
handle_extra_doses().- ...
Forces optional arguments to be passed by name and allows for future extensions without breaking existing code. Must be empty.
- n_samples
[integer(1)]The number of samples to compute. The default is 1. This argument is used only forimputation_mode = "stochastic"andimputation_mode = "custom". Deterministic mode ignores it and always returns the package's fixed minimum, mean, and maximum samples.- birth_seasonality
As defined in
shift_doses().- sample_pair
As defined in
impute_missing_doses().- imputation_mode
As defined in
impute_missing_doses().- sample_mode
As defined in
impute_missing_doses().- bandwidth
As defined in
impute_missing_doses().- zero.rm
As defined in
impute_missing_doses().- .sampler_args
As defined in
impute_missing_doses().- shift_mode
As defined in
shift_doses().- hed_assumption
As defined in
handle_extra_doses().- max_level
As defined in
handle_extra_doses().- dd_assumption
As defined in
compute_immunity().- vax_imm_type
As defined in
compute_immunity_by_type().- rho
As defined in
compute_immunity_by_type().- per_imm_type
[logical(1)]If TRUE (default), computes immunity per immunity type. If FALSE, computes immunity per vaccine.- quiet
As defined in
handle_extra_doses().- seed
[numeric(1)]A seed for reproducibility as described infurrr::furrr_options().- doses_ratio
[data.frame]This argument is deprecated as of version 0.2.0 and will be removed in future versions. Ratios are now computed internally within the imputation functions (
impute_missing_doses()), so there is no need to compute them separately and pass them as an argument.- shift_prop
As defined in
shift_doses().- immunity_samples
[data.frame]Immunity estimates samples output fromcompute_immunity_samples().- by_admin
[character]Optional character vector of administrative columns to group by when summarizing immunity samples. When provided, it must be a subset of the administrative columns defined inconfig_pviem(). By default, it groups by all administrative columns defined inconfig_pviem().- by_time
[character]Optional character vector of time columns to group by when summarizing immunity samples. When provided, it must be a subset of year and month (if applicable) columns defined inconfig_pviem(). By default, it groups by all time columns defined inconfig_pviem().
Value
compute_immunity_sample():[data.table]A single immunity-estimate sample, as returned bycompute_immunity_by_type()whenper_imm_type = TRUE, orcompute_immunity()otherwise.compute_immunity_samples():[data.table]Multiple samples of the previous function, each identified by thesamplecolumn.summarize_immunity_samples():[data.table]Summary statistics grouped by the requested administrative and time columns,serotype, and eithertypeorvaccine. Statistic columns are.mean,.sd,.median,.lowerand.upper(the empirical 2.5% and 97.5% quantiles), and.ci95land.ci95u(t-based 95% confidence limits for the mean). Quantiles describe the sample distribution; the confidence limits describe uncertainty in its mean.
Note
When furrr package is installed and plan(multisession) or friends is set, the
compute_immunity_samples() will compute the samples in parallel. This makes the computation faster.
Both by_admin and by_time arguments can be used together to specify the grouping variables
for summarizing immunity samples. If neither is provided, the function will summarize by all
administrative and time columns defined in config_pviem().