mle_fun: negative log-likelihood function

View source: R/calibrate.R

mle_funR Documentation

negative log-likelihood function

Description

negative log-likelihood function

Usage

mle_fun(
  p,
  data,
  debug = FALSE,
  debug_plot = FALSE,
  debug_hist = FALSE,
  opt_pars,
  base_params,
  start_date = min(data$date),
  end_date = max(data$date),
  time_args = NULL,
  sim_args = NULL,
  sim_fun = run_sim_break,
  checkpoint = FALSE,
  aggregate_args = NULL,
  priors = NULL,
  na_penalty = 1e+06,
  ...
)

Arguments

p

parameter vector (in unlisted form)

data

a data set to compare to, containing date/var/value (current version assumes that only a single state var is included)

debug

print debugging messages?

debug_plot

plot debugging curves? (doesn't work with parallel DEoptim)

debug_hist

keep information on parameter history?

opt_pars

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

base_params

baseline parameters (an object (vector?) of type params_pansim containing all of the parameters needed for a simulation; some may be overwritten during the calibration process)

start_date

starting date for sims (far enough back to allow states to sort themselves out)

end_date

ending date

time_args

arguments passed to sim_fun

sim_args

additional arguments to pass to run_sim

sim_fun

function for simulating a single run (e.g. run_sim_break, run_sim_mobility)

checkpoint

save file containing call information?

aggregate_args

arguments passed to aggregate.pansim

priors

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))

na_penalty

value to add to NLL for NA values in log-likelihood

...

unused (but useful in case junk needs to be discarded)

See Also

Other classic_macpan: add_d_log(), add_updated_vaxrate(), aggregate_agecats(), calibrate_comb(), 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(), 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()

Examples

library(dplyr)
p <- read_params("ICU1.csv")
op <- get_opt_pars(p)
dd <- ont_all %>% trans_state_vars() %>% filter(var %in% c("H","death"))
mle_fun(p=unlist(op), dd, opt_pars=op, base_params=p)
op <- op["params"] ## exclude log_nb_disp
try(mle_fun(p=unlist(op), dd, opt_pars=op, base_params=p))
p2 <- update(p, obs_disp=2)
mle_fun(p=unlist(op), dd, opt_pars=op, base_params=p2)
p3 <- update(p, obs_disp_H=2, obs_disp_death=2)
mle_fun(p=unlist(op), dd, opt_pars=op, base_params=p3)

bbolker/McMasterPandemic documentation built on Aug. 25, 2024, 6:35 p.m.