sd_loglik_fun {readsdr}R Documentation

Generate a log-likelihood function for an SD model

Description

Generate a log-likelihood function for an SD model

Usage

sd_loglik_fun(
  filepath,
  unknown_pars,
  meas_data_mdl,
  neg_log = FALSE,
  supplied_pars = NULL,
  start_time = NULL,
  stop_time = NULL,
  timestep = NULL,
  integ_method = "euler",
  const_list = NULL
)

Arguments

filepath

A string that indicates a path to a file with extension .stmx or .xmile. Vensim files (.mdl) are not xmile files. They must be exported from Vensim with extension .xmile

unknown_pars

A list of lists. Each second-level list contains at least the element name name, which corresponds to the parameter's name subject to estimation. In addition to the element name, users can incorporate in the sub-list the elements min and max. The value of min can only be 0, whereas the value of max can only be 1.

meas_data_mdl

A list of lists. Each second-level list corresponds to a sampling statement along with its measurements. Here is an example:
list(formula = "y ~ neg_binomial_2(net_flow(C), phi)", measurements = 1:10))

neg_log

A boolean that indicates whether the log-likelihood function returns a positive or negative value. If TRUE, the function returns a positive value (for minimisation optimisers). If FALSE, the function returns the original log-likelihood.

supplied_pars

A string vector indicating the name of parameters whose values will be supplied to the function. These values will not be subject to optimisation.

start_time

A number indicating the time at which the simulation begins.

stop_time

A number indicating the time at which the simulation ends.

timestep

A number indicating the time interval for the simulation. Also known as dt.

integ_method

A string indicating the integration method. It can be either "euler" or "rk4"

const_list

A list in which each element's name is the name of the constant to override and the element's value correspond to the new value.

Value

A list of three elements. The first element, fun, corresponds to the log likelihood function. The second element, par_names, indicates the order in which the unknowns are returned. The third element, sim_params, corresponds to the simulation parameters (start time, stop time, and the integration step or dt) employed by the solver function.

Examples

 filepath      <- system.file("models/", "SEIR.stmx", package = "readsdr")
 unknown_pars  <- list(list(par_name = "par_beta", min = 0))
 meas_data_mdl <- list(list(formula      = "y ~ neg_binomial_2(net_flow(C), phi)",
                            measurements = 1:10))
 fun_obj <- sd_loglik_fun(filepath, unknown_pars, meas_data_mdl, neg_log = FALSE,
                          start_time = 0, stop_time = 10, timestep = 1/32)

[Package readsdr version 0.3.0 Index]