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,
...
)
A data.frame()
or tibble()
containing the data
A list of alternative availabilites supplied by the user
A list of matrixes with draws for each random parameter in the model
An integer indicating the number of cores to use in estimation
A character string giving the name of the id variable
A character string giving the name of the ct variable
A character string giving the name of the choice variable
An integer giving the number of observations
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.
An environment or list of environments providing the context for evaluating the log-likelihood function.
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.