You can control the behavior of macpan2 using standard R
options. To do this, use the options() function near the
top of your script or session. Here are a couple of examples.
This page lists all macpan2 options, organized by topic.
Defaults and allowed values for each option are provided. You can copy
and paste (and perhaps modify) the examples to change package
behavior.
By default, macpan2 writes logs to the following path,
which will be different on each machine.
library(macpan2)
file.path(
getOption("macpan2_log_dir")
, ".macpan2"
, getOption("macpan2_session_name")
, "log.txt"
)
#> [1] "/github/home/.local/share/R/macpan2/.macpan2/default/log.txt"To log to the working directory, use
options(macpan2_log_dir = ""). You can also get console
output from the TMB engine using
options(macpan2_verbose = TRUE).
"default"tools::R_user_dir("macpan2")FALSE!getOption("macpan2_verbose") to
TMB::MakeADFun().Here are some examples of controlling logging and verbosity.
When a model contains only scalar variables, the default output
structure—which includes row, col, and a
generic matrix column—can be unnecessarily complex. The
following options simplify the output in these cases by:
row and col columns when they
provide no information.matrix column to something more
meaningful.| Option | Default | Affects | Renamed Column (if collapsed) |
|---|---|---|---|
| macpan2_collapse_traj | FALSE |
mp_trajectory() |
variable |
| macpan2_collapse_coef | FALSE |
mp_tmb_coef() |
par |
| macpan2_collapse_default | FALSE |
mp_default() |
quantity |
Note that macpan2_collapse_traj also applies to all
mp_trajectory_*() functions that return a data frame, such
as mp_trajectory_sd() and
mp_trajectory_par().
These options are often worth enabling in scalar-only models to
simplify results. The only reason they are not defaults is to preserve
backward compatibility with earlier versions of
macpan2.
options(
macpan2_collapse_traj = TRUE
, macpan2_collapse_coef = TRUE
, macpan2_collapse_default = TRUE
)Thanks to Jonathan Dushoff for the ideas here.
1e-8proportions() via
mp_hazard() to avoid division by zero.1e-6Here is an example.
These options are mostly for developers or advanced users.
"simulate""simulate", "report""simulate" respects set.seed();
"report" (pre-2.4.0 behavior) does not.Some engine functions have constraints based on their use in time steps or access to history.
c("convolution", "rbind_lag", "rbind_time", "cbind_lag", "cbind_time")c("time_var", "rbinom", "rpois", "rnorm", "rnbinom", "reulermultinom")"macpan2"You can use a custom engine that is an alternative version of
src/macpan2.cpp, called
project-directory/alt.cpp for example, by running the
following code:
base::message()must_save and
must_not_save are specified. Applies to
mp_tmb_model_spec() and related functions with those
arguments.These options are preserved for backward compatibility only.
"clamped_poisson""clamped_poisson", "poisson",
"sum_of_squares", "neg_bin" Please specify
loss functions for trajectory matching directly as in this
vignette section.c("state", "flow_rates", "trans_rates") |> self_named_vector()These options exist in the code but are not currently used.
"ADFun"TRUE