Top-level calibration based on mobility, splines, and
phenomenological heterogeneity. This function is a wrapper for
calibrate
, which first sets up the model matrix for
time-dependent transmission rates \(\beta(t)\). For example,
for splines, it sets up the spline basis and the coefficients of
each basis function. For mobility, it sets up the slope and
intercept parameters (since mobility is treated as a log-linear
function between break points).
calibrate_comb(
data,
params,
opt_pars = NULL,
mob_data = NULL,
mob_breaks = NULL,
mob_breaks_int = FALSE,
mob_logist_scale = NA,
spline_days = 14,
spline_setback = 0,
spline_extrap = c("linear", "constant"),
spline_df = NA,
knot_quantile_var = NA,
spline_pen = 0,
spline_type = "bs",
spline_int = FALSE,
testing_data = NULL,
maxit = 10000,
skip.hessian = FALSE,
use_DEoptim = TRUE,
DE_cores = 1,
beta_break_dates = NULL,
use_mobility = FALSE,
use_phenomhet = FALSE,
use_spline = FALSE,
use_testing = FALSE,
vars = NULL,
debug_plot = interactive(),
debug = FALSE,
debug_hist = FALSE,
return_val = c("fit", "X", "formula", "args", "time_args"),
start_date = NULL,
priors = list(),
...
)
a data set to compare to, containing date/var/value (current version assumes that only a single state var is included)
parameters
starting parameters (and structure). Parameters
that are part of the params_pansim
parameter vector can
be specified within the params
element (with prefixes
if they are transformed); other parameters can include
distributional parameters or time-varying parameters
mobility data
vector of breakpoints for piecewise mobility model
(logical) specifies whether the intercept of
the mobility/transmission relationship changes at each
mobility breakpoint. The default (FALSE
) specifies that
mobility in 'mobility period' i
is
beta0*(rel_mobility)^p_i
; TRUE
would specify
beta0*(a_i)*(rel_mobility)^p_i
, with a_1==1
.
specifies the scale of the smooth
(logistic) transition between mobility periods, in days: if it
is NA
(default), the model uses sharp breaks for a
piecewise-constant model. Otherwise, the parameter used makes
a logistic transition between the two periods with the
specified scale.
days between spline knots
days before end of time series to set
boundary knots for spline (this implies linear
extrapolation after knots if spline_type="ns"
is
specified, which is probably wise)
spline extrapolation model ("linear" or "constant")
overall spline degrees of freedom
variable to use cum dist for knotspacing
penalization for spline
spline type ("ns" for natural spline or "bs" for b-spline)
spline intercept (??)
data frame with columns containing dates
(Date
) and testing intensity (intensity
) (=
tests per capita per day)
maximum iterations for Nelder-Mead/optimization step
skip Hessian calculation?
use differential evolution as first stage?
number of parallel workers for DE
discrete break dates for transmission changes
include mobility as a covariate in the model?
include phenomenological heterogeneity?
include spline?
include variation in testing intensity?
which vars to use? (default is all in data)
plot debugging curves? (doesn't work with parallel DEoptim)
print debugging messages?
keep information on parameter history?
"fit" (return calibrated value); "X" (short-circuit/return model matrix?); "formula" (return log-linear formula for time-varying beta)
start date
a list of tilde-delimited expressions giving prior
distributions expressed in terms of the elements of
opt_pars
,
e.g. list(~dlnorm(rel_beta0[1],meanlog=-1,sd=0.5))
extra args
Other classic_macpan:
add_d_log()
,
add_updated_vaxrate()
,
aggregate_agecats()
,
calibrate()
,
check_age_cat_compatibility()
,
check_contact_rate_setting()
,
col_multiply()
,
condense_age()
,
condense_params_vax()
,
condense_state()
,
condense_vax()
,
dev_is_tikz()
,
do_step()
,
expand_params_age()
,
expand_params_desc_age()
,
expand_params_desc_variant()
,
expand_params_desc_vax()
,
expand_params_mistry()
,
expand_params_variant()
,
expand_params_vax()
,
expand_state_age()
,
expand_state_vax()
,
expand_stateval_testing()
,
fix_pars()
,
fix_stored()
,
forecast_ensemble()
,
forecast_sim()
,
getData()
,
get_GI_moments()
,
get_Gbar()
,
get_R0()
,
get_doses_per_day()
,
get_evec()
,
get_kernel_moments()
,
get_opt_pars()
,
get_r()
,
invlink_trans()
,
make_betavec()
,
make_beta()
,
make_jac()
,
make_ratemat()
,
make_state()
,
make_test_wtsvec()
,
make_vaxrate()
,
mk_Nvec()
,
mk_agecats()
,
mk_contact_rate_setting()
,
mk_mistry_Nvec()
,
mk_pmat()
,
mk_vaxcats()
,
mle_fun()
,
non_expanded_states
,
rExp()
,
read_params()
,
repair_names_age()
,
restore()
,
run_sim_ageify()
,
run_sim_break()
,
run_sim_loglin()
,
run_sim_mobility()
,
run_sim_range()
,
run_sim()
,
show_ratemat()
,
testify()
,
texify()
,
trans_state_vars()
,
update_contact_rate_setting()
,
update_foi()
,
update_params_mistry()
,
vis_model()
,
write_params()
if (require(dplyr)) {
dd <- ont_all %>% trans_state_vars() %>%
filter(var %in% c("H","report"))
params <- read_params("ICU1.csv")
## quick and dirty example (maximize speed)
if (FALSE) {
calibrate_comb(data=dd, params=params,
use_spline=TRUE,
maxit=10, skip.hessian=TRUE, use_DEoptim =FALSE)
X <- calibrate_comb(data=dd, params=params,
use_spline=TRUE,
spline_type="ns",
spline_setback=1,
spline_extrap="constant",
return_val="X")
matplot(X, ylab="")
form <- calibrate_comb(data=dd, params=params,
use_spline=TRUE,
spline_type="ns",
spline_setback=1,
spline_extrap="constant",
return_val="formula")
print(form)
}
}