The estimation environment provides the context for evaluating the log-likelihood function. Creating an environment allow us to call parameters, variables and indexes directly without calls to attach and detach.

prepare_estimation_environment(
  db,
  alt_avail,
  draws,
  cores,
  str_id,
  str_ct,
  str_choice,
  n_obs,
  param_fixed,
  ...
)

Arguments

db

A data.frame() or tibble() containing the data

alt_avail

A list of alternative availabilites supplied by the user

draws

A list of matrixes with draws for each random parameter in the model

cores

An integer indicating the number of cores to use in estimation

str_id

A character string giving the name of the id variable

str_ct

A character string giving the name of the ct variable

str_choice

A character string giving the name of the choice variable

n_obs

An integer giving the number of observations

param_fixed

A list of fixed parameters to add to environment

...

Additional objects passed on to the estimation environment. NOTE: these are NOT split by core or respondents, but exported in its entirety.

Value

An environment or list of environments providing the context for evaluating the log-likelihood function.

Details

The use of an estimation environment also makes debugging easy because it is possible attach the environment directly to run through the log-likelihood function line-by-line. To efficiently debug, it is important that the number of cores is set to 1.

To run the model on subsets of the data, simply pass a subset of the data using the db argument.