Package: macpan2 3.5.1

Ben Bolker

macpan2: Fast and Flexible Compartmental Modelling

Tools for building and calibrating compartmental models of infectious disease.

Authors:Steve Walker [aut], Weiguang Guan [aut], Jen Freeman [aut], Ben Bolker [cre, aut], Darren Flynn-Primrose [aut], David J.D. Earn [ctb], Jonathan Dushoff [ctb], Irena Papst [ctb], Michael Li [ctb], Kevin Zhao [ctb]

macpan2_3.5.1.tar.gz
macpan2_3.5.1.zip(r-4.7)macpan2_3.5.1.zip(r-4.6)macpan2_3.5.1.zip(r-4.5)
macpan2_3.5.1.tgz(r-4.6-x86_64)macpan2_3.5.1.tgz(r-4.6-arm64)macpan2_3.5.1.tgz(r-4.5-x86_64)macpan2_3.5.1.tgz(r-4.5-arm64)
macpan2_3.5.1.tar.gz(r-4.7-arm64)macpan2_3.5.1.tar.gz(r-4.7-x86_64)macpan2_3.5.1.tar.gz(r-4.6-arm64)macpan2_3.5.1.tar.gz(r-4.6-x86_64)
macpan2_3.5.1.tgz(r-4.6-emscripten)
manual.pdf |manual.html
card.svg |card.png
macpan2/json (API)
NEWS

# Install 'macpan2' in R:
install.packages('macpan2', repos = c('https://canmod.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/canmod/macpan2/issues

Pkgdown/docs site:https://canmod.github.io

Uses libs:
  • c++– GNU Standard C++ Library v3

On CRAN:

Conda:

compartmental-modelsepidemiologyforecastingmixed-effectsmodel-fittingoptimizationsimulationsimulation-modelingcpp

9.00 score 8 stars 1 packages 313 scripts 171 exports 11 dependencies

Last updated from:13837d8225. Checks:13 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK340
linux-devel-x86_64OK366
source / vignettesOK580
linux-release-arm64OK334
linux-release-x86_64OK382
macos-release-arm64OK366
macos-release-x86_64OK722
macos-oldrel-arm64OK376
macos-oldrel-x86_64OK690
windows-develOK340
windows-releaseOK331
windows-oldrelOK338
wasm-releaseOK196

Exports:all_consistentall_equalall_not_equalBinaryOperatorCSVReaderdot_layoutempty_matrixempty_trajectoryengine_evalfind_all_pathsJSONReaderLogLogitmp_absolute_flowmp_adjacencymp_aggregatemp_binary_operatormp_cartesianmp_change_framemp_defaultmp_default_listmp_discrete_stochmp_dot_layoutmp_dynamic_modelmp_dynamic_simulatormp_dynamic_varsmp_effects_descrmp_eulermp_euler_multinomialmp_expandmp_extractmp_factorsmp_finalmp_final_listmp_fitmp_flow_framemp_flow_varsmp_forecastermp_functions_usedmp_generates_randomnessmp_groupmp_hazardmp_identitymp_indexmp_inflowmp_initialmp_initial_listmp_joinmp_kronecker_operatormp_labelsmp_layout_gridmp_layout_pathsmp_ledgersmp_linearmp_list_modelsmp_lnormmp_logmp_log_normalmp_log1pmp_logitmp_logit_normalmp_logitnormmp_lookupmp_model_docsmp_model_startermp_nbinommp_neg_binmp_nofitmp_normmp_normalmp_official_librarymp_opt_attemptedmp_optimizemp_optimized_specmp_optimizer_outputmp_other_dynamic_varsmp_outflowmp_parmp_parameterizationmp_per_capita_flowmp_per_capita_inflowmp_per_capita_outflowmp_poismp_poissonmp_positionsmp_print_aftermp_print_beforemp_print_duringmp_print_obj_fnmp_print_specmp_rbfmp_read_rdsmp_reducemp_referencemp_renamemp_rk4mp_rk4_oldmp_set_numbersmp_setdiffmp_show_modelsmp_sim_boundsmp_sim_offsetmp_simulatormp_slicesmp_sqrtmp_squaremp_state_dependence_framemp_state_flow_varsmp_state_varsmp_structured_vectormp_subsetmp_symmetricmp_time_scalemp_tmbmp_tmb_calibratormp_tmb_coefmp_tmb_deletemp_tmb_entire_librarymp_tmb_expr_listmp_tmb_fixef_covmp_tmb_implicit_backtransmp_tmb_implicit_transmp_tmb_insertmp_tmb_insert_backtransmp_tmb_insert_glm_timevarmp_tmb_insert_log_linearmp_tmb_insert_reportsmp_tmb_insert_transmp_tmb_librarymp_tmb_model_specmp_tmb_objectivemp_tmb_profilemp_tmb_updatemp_tmbstan_coefmp_trajmp_trajectorymp_trajectory_ensemblemp_trajectory_parmp_trajectory_replicatemp_trajectory_sdmp_trajectory_simmp_trianglemp_uncertainty_estimatedmp_unifmp_uniformmp_unionmp_versionmp_version_updatemp_zero_vectornlistnot_all_equalNULLReaderrbfReaderRReadershow_modelssi_example_codesi_example_objectsimple_simssparse_matrix_notationStringDataFromDottedStringDataFromFrameto_labelsto_nameto_name_pairsto_namesto_positionsto_stringto_valuesTransformTXTReader

Dependencies:cachemfastmaplatticeMASSMatrixmemoiseoorRcppRcppEigenrlangTMB

Advanced Calibration

Rendered fromcalibration_advanced.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-05-21
Started: 2024-02-22

Advanced Specification of Time-Varying Parameters

Rendered fromtime_varying_parameters_advanced.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2024-04-08
Started: 2024-04-08

Article Status

Rendered fromvignette_status.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2023-05-31
Started: 2023-05-31

Calibrating Compartmental Models to Data

Rendered fromcalibration.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-07-09
Started: 2023-06-09

Composing Related Simulation Models

Rendered fromcomposing_simulation_models.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2023-06-14
Started: 2022-11-02

Debugging

Rendered fromdebugging.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2024-01-18
Started: 2024-01-18

Design Concepts

Rendered fromdesign_concepts.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-06-02
Started: 2024-01-19

Development Principles and Patterns

Rendered fromdevelopment_patterns.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-03-19
Started: 2023-05-31

Elementwise Binary Operators

Rendered fromelementwise_binary_operators.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-04-09
Started: 2022-11-02

Engine-Agnostic Model Specification Grammar

Rendered fromengine_agnostic_grammar.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-06-02
Started: 2024-01-18

Example Models

Rendered fromexample_models.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-02-20
Started: 2023-05-31

FAQs

Rendered fromFAQs.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-07-09
Started: 2024-11-06

Fitting to Real Data

Rendered fromreal_data.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-07-09
Started: 2024-02-26

Multiplying Matrices in macpan2 Models

Rendered frommatrix_multiplication.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-08-23
Started: 2025-07-30

ODE Solvers, Process Error, and Difference Equations

Rendered fromstate_updaters.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2024-10-02
Started: 2024-03-05

Options

Rendered fromoptions.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-08-06
Started: 2025-02-19

Quickstart

Rendered fromquickstart.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-08-06
Started: 2023-04-06

Specifying Likelihood and Prior Components

Rendered fromlikelihood_prior_specs.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-07-09
Started: 2024-10-07

Specifying Time-Varying Parameters

Rendered fromtime_varying_parameters.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2024-05-17
Started: 2023-05-31

State-Dependent Rates

Rendered fromstate_dependent_rates.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-07-31
Started: 2023-03-31

Structured SI Model with Kronecker Products in macpan2

Rendered fromkronecker.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-07-31
Started: 2025-07-30

The C++ Side

Rendered fromcpp_side.Rmdusingknitr::rmarkdownon Jun 10 2026.

Last update: 2025-04-22
Started: 2022-08-25

Readme and manuals

Help Manual

Help pageTopics
Binary OperatorBinaryOperator mp_binary_operator
Comparison Functionsall_consistent all_equal all_not_equal comparison not_all_equal
Distributionsdistribution mp_lnorm mp_logitnorm mp_logit_normal mp_log_normal mp_nbinom mp_neg_bin mp_norm mp_normal mp_pois mp_poisson mp_unif mp_uniform
Create a Graph from a Model Specificationdot_layout mp_dot_layout
Empty Matrixempty_matrix
Empty Trajectoryempty_trajectory
Engine Evaluationengine_eval
Functions Available in the Simulation Engineassign block c cbind cbind_lag cbind_time check_finite clamp col_sums convolution cos cumsum dbinom divide_safe dnbinom dnorm dpois engine_functions exp from_diag group_sums invlogit last log logit matrix mean pgamma pnorm print proportions rbind rbind_lag rbind_time rbinom recycle rep reulermultinom rnbinom rnorm round row_sums rpois sd seq sin sparse_mat_mult sqrt sum t time_group time_step time_var to_diag unpack `%*%` `%x%` `(` `*` `+` `-` `/` `:` `[` `^`
Find all Paths Through Compartmentsfind_all_paths
Fitting Distributional Parametersfit_distr_params mp_fit mp_nofit
LedgersLedgerDefinition
Specify Absolute Flow Between Compartments (Experimental)mp_absolute_flow
Adjacency Matrixmp_adjacency
Aggregate an Indexmp_aggregate
Cartesian Product of Index Tablesmp_cartesian
Data Frame Describing Each Change to Each State Variablemp_change_frame
Default Valuesmp_default mp_default_list
Dynamic Modelmp_dynamic_model
TMB Simulator from Dynamic Modelmp_dynamic_simulator
Describe Statistical Effectsmp_add_effects_descr mp_effects_descr
Expand Modelmp_expand mp_reduce
Extract Indexmp_extract
Factor an Indexmp_factors
Final Valuesmp_final mp_final_list
Data Frame Describing Compartmental Model Flowsmp_flow_frame
Make a Forecastermp_forecaster
Functions Used by an Object for Communicating with a Computational Enginemp_functions_used mp_generates_randomness
Group an Indexmp_group
Model Quantity Index Tablemp_index names.Index print.Index
Initial Values of Variables Immediately Before the Simulation Loopmp_initial mp_initial_list
Join Indexesmp_join
Kronecker Operatormp_kronecker_operator
Index Labelsmp_labels
Flow Diagram Grid Layout (experimental)mp_layout_grid
Flow Diagram Grid Layout (experimental)mp_layout_paths
Bundle up Ledgersmp_ledgers
Linear Chain Productmp_linear
Lookupmp_lookup
Browse Model Docsmp_model_docs
Copy Existing Model as a Starting Pointmp_model_starter
Optimization Attemptedmp_opt_attempted
Optimize Simulation Modelmp_optimize
Optimized Model Specificationmp_optimized_spec
Optimizer Outputmp_optimizer_output
Fit Parametersmp_par
Description of Model Parameterizationmp_parameterization
Specify Flow Into, Out Of, and Between Compartmentsmp_inflow mp_outflow mp_per_capita_flow mp_per_capita_inflow mp_per_capita_outflow
Position Vectorsmp_positions
Print Objective Functionmp_print_obj_fn
Print Model Specificationmp_print_after mp_print_before mp_print_during mp_print_spec
Fit a Time-Varying Parameter with Radial Basis Functionsmp_rbf
Read Serialized Model Specificationmp_read_rds
Reference Indexmp_reference
Rename Index Columnsmp_rename
Print a Table of Existing Modelsmp_list_models mp_show_models show_models
Simulation Boundsmp_sim_bounds
Simulation Offsetsmp_sim_offset
Create a Simulatormp_simulator
Slice an indexmp_slices
Self Cartesian Productmp_square
Data Frame Describing State Dependent Per-Capita Flow Ratesmp_state_dependence_frame
Structured Vectorsmp_set_numbers mp_structured_vector
Subset of Indexesmp_setdiff mp_subset
Symmetric Self Cartesian Productmp_symmetric
Time Scalemp_time_scale
Get Underlying TMB Objectmp_tmb
Make a Calibratormp_tmb_calibrator
TMB Model Coefficient Tablemp_tmb_coef
Expression Listmp_tmb_expr_list
Covariance of Fixed Effect Estimatesmp_tmb_fixef_cov
Transform a TMB Model Specificationmp_tmb_delete mp_tmb_insert mp_tmb_update
Insert Back Transformations of Model Parametersmp_tmb_implicit_backtrans mp_tmb_insert_backtrans
Insert GLM Time Variationmp_tmb_insert_glm_timevar
Insert Log Linear Model of Time Variation (Experimental)mp_tmb_insert_log_linear
Transform a TMB Model Specification to Account for Reporting Biasmp_tmb_insert_reports
Insert Basic Transformations of Model Variablesmp_tmb_implicit_trans mp_tmb_insert_trans
Read Item from a Model Librarymp_official_library mp_tmb_entire_library mp_tmb_library
Create TMB Model Specificationmp_tmb_model_spec
Value of the Objective Function of a Modelmp_tmb_objective
TMB Likelihood Profilingmp_tmb_profile
Model Coefficient Table with stanmp_tmbstan_coef
Trajectory Specificationmp_traj
Simulate Dynamical Model Trajectoriesmp_trajectory mp_trajectory_ensemble mp_trajectory_par mp_trajectory_replicate mp_trajectory_sd mp_trajectory_sim
Self Cartesian Product Excluding One Off-Diagonal Sidemp_triangle
Uncertainty Estimatedmp_uncertainty_estimated
Union of Indexesmp_union
Dynamic Variable Namesmp_dynamic_vars mp_flow_vars mp_other_dynamic_vars mp_state_flow_vars mp_state_vars mp_vars
Version of 'macpan2'mp_version
Version Updatemp_version_update
Zero Vectormp_zero_vector
Names and Labelsnames_and_labels to_labels to_name to_names to_name_pairs to_values
Self Naming Listnlist
Radial Basis Functionsrbf
ReaderCSVReader JSONReader NULLReader Reader RReader TXTReader
SI Examplesi_example si_example_code si_example_object
Simple Iterated Simulationsimple_sims
Extract Sparse Matrix Notation from a Dense Matrixsparse_matrix_notation
Change How State Variables are Updatedmp_discrete_stoch mp_euler mp_euler_multinomial mp_hazard mp_rk4 mp_rk4_old state_updates
String Dataprint.StringData StringData StringDataFromDotted StringDataFromFrame
To Positionsto_positions
To Stringto_string
TransformIdentity Log Logit Transform
Link Functions and Transformationmp_identity mp_log mp_log1p mp_logit mp_sqrt transform_distr_param