All functions

McMasterPandemic-package

McMasterPandemic

add_conv()

Add Variable by Convolution

add_factr()

Intermediate Factors

add_lag_diff() add_lag_diff_uneven()

Add Variable by Lag Differencing

add_opt_params() update_opt_params() initialize_opt_params() initialize_opt_tv_params() update_opt_tv_params() add_opt_tv_params()

Optimization Parameters

add_linearized_outflow() add_outflow()

Add Outflows

add_parallel_accumulators()

Add Parallel Accumulators

add_pow()

Add Power Law

add_rate()

Add Rate

add_sim_report_expr()

Add Expression to the Simulation History

add_state_mappings()

Add State Mappings

add_state_param_sum()

Sums of States and Parameters

add_updated_vaxrate()

compute and add vaxrates to ratemat (returns whole ratemat because the update part is non-trivial)

aggregate(<pansim>)

Temporal aggregation of pansim objects

aggregate_agecats()

Aggregate age categories into larger age categories

as.character(<struc>)

Convert struc Object to a character vector

as.flexmodel() as.flexmodel_to_calibrate() as.flexmodel_obs_error() as.flexmodel_one_step()

Convert between Types of Flexmodels

as.matrix(<struc>)

Convert struc Object to a matrix

avail_for_rate() avail_for_sum() avail_for_factr() avail_for_pow() avail_for_expr() avail_for_conv() avail_for_lag()

What Variables are Available?

calc_conv()

calculate convolution

calibrate()

Estimate model parameters from data

calibrate_comb()

Combined calibration of model to multiple types of data

calibrate_flexmodel()

Calibrate Flexmodel

check_age_cat_compatibility()

Check compatibility of user-specified age categories with age categories in Mistry data

check_contact_rate_setting()

Helper function to check setting-specific contact rate list initialization

col_multiply()

Compute elementwise multiplication of a vector by each column in a matrix This is implemented for performance reasons, as it is much faster than sweep.

compare_grads() compare_hessians()

Compare Automatic and Numerical Differentiation

compare_sims() compare_sims_cbind() compare_sims_plot() compare_sims_diffmat() compare_sims_unlist()

Compare TMB-based and classic MacPan Simulations

complement() inverse()

Symbolic Complement and Inverse

condense()

condense an object

condense(<pansim>)

Condense columns (infected, ICU, hospitalized) in a pansim output

condense_age()

collapse age/testing/etc. categories (only; don't do other condensation)

condense_params_vax()

condense vaxified parameters to base parameters

condense_state()

collapse (non-accumulator) states into subcategories (ages, vax status)

condense_vax()

collapse vaccination categories (only; don't do other condensation)

const_named_vector()

Constant Named Vector

cross_mat()

Cross Two Sets of Names in Matrix Form

changing_ratemat_elements() simulate_changing_ratemat_elements() concatenated_state_vector() simulate_state_vector() initial_state_vector() final_state_vector() penultimate_state_vector() final_state_ratio() initial_ratemat() simulation_condensed() condense_flexmodel() simulate(<flexmodel>) simulation_fitted()

Deprecated Simulation Functions

describe_params()

Describe parameters

dev_is_tikz()

Is tikzDevice currently in use?

distribute_counts()

distribute counts given a desired distribution (with smart rounding)

do_step()

Take a single simulation time step

expand_struc()

Expand and Contract struc and struc_expanded Objects

expand_names()

Expand Names

expand_params_S0()

Expand Parameter List to Include Initial Proportion of Susceptibles

expand_params_age()

Expand parameter list to include age structure

expand_params_desc_age()

Edit parameter description attribute to include age-specific definitions (helper function for `expand_params_age()`)

expand_params_desc_variant()

Edit parameter description attribute to include variant-specific definitions (helper function for `expand_params_variant()`)

expand_params_desc_vax()

Edit parameter description attribute to include vax-specific definitions (helper function for `expand_params_vax()`)

expand_params_mistry()

Expand parameter list to include age structure using Mistry et al. data

expand_params_variant()

Expand parameter list to include variant strain

expand_params_vax()

Expand parameter list to include vaccination

expand_state_age() ageify()

expand state vector by age classes and population distribution

expand_state_vax()

expand state vector by vaccination status

expand_stateval_testing()

expand states and values to include

extend_end_date()

Extend End Date

factory_fresh_macpan_options()

Factory Fresh MacPan Options

fix_pars()

adjust pars to match targets

fix_stored()

convert 'old' forecast args to 'new' format

flexmodel() init_model()

Initialize Flexible Compartmental Model

forecast_ensemble()

find confidence envelopes by simulation

forecast_sim()

simulate/forecast a single trajectory

getData()

extract and return original fitting data

get_GI_moments()

compute moments of generation interval (mean and CV^2)

get_Gbar()

compute mean generation interval from parameters

get_R0()

calculate R0 for a given set of parameters

pars_base_sim() pars_base_init() pars_base_opt() pars_time_sim() pars_time_spec() pars_time_opt() pars_time_series() pars_infer_init() pars_infer_opt() pars_infer_conf() `pars_base_sim<-`()

Get and Set Model Parameters

get_doses_per_day()

Compute total number of vaccine doses actually administered per day in a simulation

get_evec()

get dominant eigenvector

get_kernel_moments()

compute R0, r, etc. based on kernel computation

get_macpan_options()

Get McMasterPandemic Options

get_opt_pars()

generate reasonable default opt_pars

get_r()

return growth rate (from Jacobian)

gradfun()

gradient function for ODE runs

index_sep()

Get Substrings by Indices and Separators

initial_population()

Initial Population

invlink_trans()

apply inverse-link functions to parameter vector or list based on names

is_1by1()

Test if 1-by-1

layered_zero_state()

Layered Zero State Vector

alt_group() wrap_exact() all_in() any_var() all_except()

Regular Expression Conveniences

make_ageified_model()

Converts a classic ageified model to a flexmodel

make_base_model()

Represent a Standard Unstructured Model as a flexmodel

make_beta()

construct vector of transmission multipliers

make_betavec()

construct vector of transmission multipliers

make_delay_kernel()

construct a Gamma-distributed delay kernel

make_hello_world_model()

Hello World

make_jac()

construct Jacobian matrix for ICU model (not quite complete: doesn't include flows to R)

make_omicron_model()

Make an Omicron invasion model

make_ratemat()

Create transition matrix

make_sir_model()

SIR Model

make_state()

retrieve parameters from a CSV file

make_test_wtsvec() make_test_posvec()

make weights vector for tests

make_vaccination_model()

Make a Two-Dose Vaccination Model

make_vaxrate()

generate per capita daily vaccination rates

mat_rate()

Specify Matrix of Rates

merge_named_vec_attr()

Merge Named Vector Attribute

merge_named_vectors()

Merge One Vector into Another by Name

mk_Nvec()

generate a population distribution (as a vector of counts)

mk_agecats()

Construct vector of age category labels

mk_contact_rate_setting()

Helper function to generate a vector of setting-specific contact rates

mk_mistry_Nvec()

Make population distribution using Mistry et al. data

mk_pmat()

generate a contact matrix (where each row is a probability distribution)

mk_vaxcats()

Construct vector of vaccine category labels

mle_fun()

negative log-likelihood function

nlist()

self-naming list (copied from lme4:::namedList)

non_expanded_states test_extensions test_accumulators asymp_cat severe_cat cryptic_cat

global variables for testify expansion

ont_all comb_sub ont_all_sub

Sample data and fit from Ontario (up to 2020-04-18)

ont_cal1 ont_cal_2brks ont_cal_mob1 bd

Fitted models to Ontario data

opt_obj() convergence_info()

Optimizer Object

optim_flexmodel() nlminb_flexmodel() bbmle_flexmodel() fitted(<flexmodel_calibrated>)

Wrapped Optimizers for Flexmodels

parse_formula() rateform_as_char()

Parse a Flexmodel Formula

pivot()

pivot an object

plot(<pansim>)

plot method for simulations

plot(<predict_pansim>)

plot forecasts from fits

plot_res_by_age()

Plot age-structured simulation result faceted by age categories

plot_res_by_state()

Plot age-structured simulation result faceted by state

predict(<fit_pansim>) plot(<fit_pansim>)

make forecasts from sim

prep_res_for_plotting()

Prepare age-structured simulation results data frame for plotting

print(<params_pansim>)

print parameters, possibly with detailed description

rExp()

run a pure-exponential sim; uses run_sim_range with a population of 1 (proportions) and a very small starting value, run for 100 steps (by default) used to calculate either r (technically r0) or eigenvector (for distributing initial exposed across states)

r_mode()

R Mode

r_tmb_comparable()

Compare R and TMB Engines

rate_summary()

Rate Summary

read_params()

read simulation parameters

rep_rate()

Repeat a Rate for Several Rate Matrix Elements

repair_names_age()

Repair ageified names

restore()

convert a parameter vector back to a structured list Like relist, but adds the capability to fill in parameters from a "fixed-parameter" vector

run_sim()

Run pandemic simulation

run_sim_ageify()

Ageify a basic simulation

run_sim_break()

run simulation with one or more breakpoints

run_sim_loglin()

run with log-linear model applied to beta

run_sim_mobility()

run with transmission propto relative mobility

run_sim_range()

Run simulation across a range of times

same_dims()

Test if struc Objects have the Same Dimensions

set_spec_version() reset_spec_version()

Set and Reset Spec Version

show_ratemat()

visualize rate (per-capita flow) matrix

simulate_ensemble()

Ensemble Simulation

simulation_history()

Simulation History

spec_check() feature_check()

Spec and Feature Checks

spec_version() spec_ver_eq() spec_ver_gt() spec_ver_lt() spec_ver_btwn()

Spec Version

`%_%` `%~%` `%+%`

String Concatenation Operators

`*`(<struc>,<struc>) `+`(<struc>,<struc>) `%*%`(<struc>,<struc>) kronecker(<struc>,<struc>) t(<struc>) sum(<struc>) prod(<struc>) rowSums(<struc>) colSums(<struc>) dim(<struc>)

Class to Represent Scalar, Vector, or Matrix Structure

struc() scal() vec() mat() as.struc()

Construct a struc Object

struc_block()

Repeat a Block

struc_eval()

Numerically Evaluate Struc Object

struc_expanded-class

Class to Represent an Expanded Matrix Structure Object

struc_expanded()

Construct a struc_expanded Object

struc_stretch()

Stretch a Block

summary(<params_pansim>)

summary method for pansim parameter objects

testify()

expand rate matrix for testing status

texify()

Convert expression string to TeX format

tibble_row_to_named_vec()

convert a tibble row (with all entries of the same data type) to a named vector (used in `condense_state()`)

time_wrap()

Time Two Expressions

tmb_fun() tmb_fun_args()

Make Objective Function with TMB

tmb_mode()

TMB Mode

tmb_params()

Extract Parameter Vector to Pass to a TMB Function

tmb_params_trans()

Parameter Vectors Transformed for TMB

topological_sort()

Topological Sort

trans_state_vars()

Translate state variables

unpack()

unpack a list into the current (calling) environment this is a replacement for with() (which is hard to debug) and attach() (which is frowned upon by CRAN/triggers package-check warnings) (for more traditional Python tuple unpacking see the zeallot package)

update(<params_pansim>)

update parameters within a list of parameters

update_condense_map()

Specify and Name Variables for Condensation

update_contact_rate_setting()

Helper function to update setting-specific contact rate list

update_disease_free_state()

Update Disease-Free State

add_error_dist() update_error_dist() reset_error_dist()

Update Error Distribution

update_foi()

calculate only updated force of infection at present, this is the only state-dependent per capita rate maybe more efficient than modifying & returning the whole matrix

update_initial_state()

Update Initial State

update_linearized_params()

Update Linearized Model Parameters

update_loss_params()

Update Observation Error

update_observed()

Update Observed Data

update_params()

Update Default Parameters

update_params_mistry()

Update Mistry-based parameters

update_piece_wise() add_piece_wise() initialize_piece_wise()

Update the Piece-Wise Parameter Time-Variation Schedule

update_ranef_params()

Update Random Effect Parameters

update_simulation_bounds()

Update Simulation Bounds

update_tmb_indices() add_tmb_indices() tmb_indices()

Update TMB Indices

v2d()

Vector to Data Frame

vec_factr()

Vectors of Intermediate Factors

vec_rate()

Specify Vector of Rates

vis_model()

display flow chart on current graphics device

write_params()

write parameters to CSV file