Skip to contents

Specifications

Create Model Specifications

Functions for creating new model specification objects, which describe dynamical models with special support for compartmental modelling. The vignette("quickstart") article describes how these functions are used in context.

Find Model Specifications

Functions for finding, copying, and loading existing model specification objects from model libraries. The vignette("example_models") article describes how these functions are used in context.

Read Item from a Model Library:
mp_tmb_library() mp_tmb_entire_library()
Print a Table of Existing Models:
mp_show_models() show_models() mp_list_models()
Copy Existing Model as a Starting Point:
mp_model_starter()
Browse Model Docs:
mp_model_docs()

Transform Model Specifications

Functions that take a model specification as input and return a modified version of that specification.

Transform a TMB Model Specification:
mp_tmb_insert() mp_tmb_update() mp_tmb_delete()
Transform a TMB Model Specification to Account for Reporting Bias:
mp_tmb_insert_reports()
Insert Log Linear Model of Time Variation (Experimental):
mp_tmb_insert_log_linear()
Insert Basic Transformations of Model Variables:
mp_tmb_insert_trans() mp_tmb_implicit_trans()
Insert Back Transformations of Model Parameters:
mp_tmb_insert_backtrans() mp_tmb_implicit_backtrans()
Change How State Variables are Updated:
mp_euler() mp_rk4() mp_rk4_old() mp_euler_multinomial() mp_discrete_stoch() mp_hazard()
Expand Model:
mp_expand() mp_reduce()

Unpack Model Specifications

Functions that extract or print information contained within model specifications.

Print Model Specification:
mp_print_spec() mp_print_before() mp_print_during() mp_print_after()
Initial Values of Variables Immediately Before the Simulation Loop:
mp_initial() mp_initial_list()
Default Values:
mp_default() mp_default_list()
Data Frame Describing Compartmental Model Flows:
mp_flow_frame()
Data Frame Describing Each Change to Each State Variable:
mp_change_frame()
State and Flow Variable Names:
mp_state_vars() mp_flow_vars() mp_state_flow_vars()
Data Frame Describing State Dependent Per-Capita Flow Rates:
mp_state_dependence_frame()

Simulators

Create New Model Simulators

Functions for creating a model simulator object.

Create a Simulator:
mp_simulator()

Generate Simulations

Functions that generate simulations from a simulator object.

Simulate Dynamical Model Trajectories:
mp_trajectory() mp_trajectory_par() mp_trajectory_sd() mp_trajectory_ensemble() mp_trajectory_sim() mp_trajectory_replicate()
Initial Values of Variables Immediately Before the Simulation Loop:
mp_initial() mp_initial_list()
Final Values:
mp_final() mp_final_list()

Unpack Model Simulators

Functions that extract or print information contained within model simulators.

Default Values:
mp_default() mp_default_list()
Get Underlying TMB Object:
mp_tmb()

Calibrators

Create Model Calibrator

Create a simulator that can be calibrated to data

Make a Calibrator:
mp_tmb_calibrator()
Fit Parameters:
mp_par()
Trajectory Specification:
mp_traj()
Fit a Time-Varying Parameter with Radial Basis Functions:
mp_rbf()
Link Functions and Transformation:
mp_identity mp_log mp_logit mp_sqrt
Simulation Bounds:
mp_sim_bounds()
Simulation Offsets:
mp_sim_offset()
Time Scale:
mp_time_scale()

Specify Distributional Assumptions

Functions for specifying distributional assumptions for priors and likelihoods.

Optimize Calibrator Model

Functions that take a model calibrator as input and calibrate model parameters, as well as functions that extract underlying objects used during the opimization/calibration process.

Optimize Simulation Model:
mp_optimize()
Optimizer Output:
mp_optimizer_output()
Optimized Model Specification:
mp_optimized_spec()
Value of the Objective Function of a Model:
mp_tmb_objective()

Generate Calibrated Simulations, Parameters, and Forecasts

Functions that generate simulations and tables of fitted parameters from a calibator object.

Simulate Dynamical Model Trajectories:
mp_trajectory() mp_trajectory_par() mp_trajectory_sd() mp_trajectory_ensemble() mp_trajectory_sim() mp_trajectory_replicate()
TMB Model Coefficient Table:
mp_tmb_coef()
Describe Statistical Effects:
mp_effects_descr() mp_add_effects_descr()
Covariance of Fixed Effect Estimates:
mp_tmb_fixef_cov()
Model Coefficient Table with stan:
mp_tmbstan_coef()
Make a Forecaster:
mp_forecaster()

Generate Fitted Parameter Tables

Unpack Model Calibrators and Calibrations

Functions that extract or print information contained within model calibrators.

Get Underlying TMB Object:
mp_tmb()
Description of Model Parameterization:
mp_parameterization()

Utilities

Lightweight Simulation Utilities

Simple functions for simulation without simulator objects, so that the ?engine_functions can be explored in isolation from compartmental models.

Engine Evaluation:
engine_eval()
Simple Iterated Simulation:
simple_sims()

Creating Matrices, Vectors, and Lists

Utilities for constructing matrices, vectors, and lists for use with macpan2.

Self Naming List:
nlist()
Empty Matrix:
empty_matrix
Empty Trajectory:
empty_trajectory
Zero Vector:
mp_zero_vector()
Radial Basis Functions:
rbf()
Binary Operator:
BinaryOperator() mp_binary_operator()

Developer Utilities

Utilities for macpan2 developers. TODO: Justify why these are exposed to users or do not expose.

Finalizers:
finalizer_char() finalizer_index()
Initial Valid Variables:
initial_valid_vars()
Generate an Arithmetic Expression Parser:
make_expr_parser()
Expression List:
mp_tmb_expr_list()
Functions Used by an Object for Communicating with a Computational Engine:
mp_functions_used() mp_generates_randomness()
Reader:
Reader() CSVReader() JSONReader() TXTReader() RReader() NULLReader()
Transform:
Transform() Identity() Log() Logit()

Not Ready

Box Diagram Layouts (Not Ready)

Functions for semi-automatically laying out compartments in model specifications as boxes on a plot.

Flow Diagram Grid Layout (experimental):
mp_layout_grid()
Flow Diagram Grid Layout (experimental):
mp_layout_paths()
Find all Paths Through Compartments:
find_all_paths()
Create a graph from a model specification:
dot_layout()

Structured Populations (Not Ready)

Functions for specifying population structure (e.g., age, space, immunity status).

Dynamic Model:
mp_dynamic_model()
TMB Simulator from Dynamic Model:
mp_dynamic_simulator()
Ledgers:
LedgerDefinition
Cartesian Product of Index Tables:
mp_cartesian()
Extract Index:
mp_extract()
Model Quantity Index Table:
mp_index() print(<Index>) names(<Index>) labelling_column_names(<Index>) labels(<Index>)
Join Indexes:
mp_join()
Linear Chain Product:
mp_linear()
Position Vectors:
mp_positions()
Reference Index:
mp_reference()
Rename Index Columns:
mp_rename()
Self Cartesian Product:
mp_square()
Symmetric Self Cartesian Product:
mp_symmetric()
Self Cartesian Product Excluding One Off-Diagonal Side:
mp_triangle()
Factor an Index:
mp_factors()
Group an Index:
mp_group()
Index Labels:
mp_labels()
Bundle up Ledgers:
mp_ledgers()
Lookup:
mp_lookup()
Slice an index:
mp_slices()
Structured Vectors:
mp_structured_vector() mp_set_numbers()
Subset of Indexes:
mp_subset() mp_setdiff()
Union of Indexes:
mp_union()
Names and Labels:
to_labels() to_names() to_name() to_name_pairs() to_values()
To Positions:
to_positions()
To String:
to_string()
Aggregate an Index:
mp_aggregate()
String Data:
StringDataFromFrame() StringDataFromDotted() print(<StringData>)
Comparison Functions:
all_equal() all_consistent() not_all_equal() all_not_equal()