Calculates the probabilities of an exploded logit model and can also perform other operations based on the value of the functionality
argument.
The function calculates the probability of a ranking as a product of logit models with gradually reducing availability, where scale differences can be allowed for.
apollo_el(el_settings, functionality)
List of inputs of the exploded logit model. It shoud contain the following.
"alternatives"
: Named numeric vector. Names of alternatives and their corresponding value in choiceVar
.
"avail"
: Named list of numeric vectors or scalars. Availabilities of alternatives, one element per alternative. Names of elements must match those in alternatives
. Values can be 0 or 1.
"choiceVars"
: List of numeric vectors. Contain choices for each position of the ranking. The list must be ordered with the best choice first, second best second, etc. It will usually be a list of columns from the database.
"V"
: Named list of deterministic utilities . Utilities of the alternatives. Names of elements must match those in alternatives.
"scales"
: List of vectors. Scale factors of each logit model. Should have one element less than choiceVars. At least one element should be normalized to 1. If omitted, scale=1 for all positions is assumed.
"rows"
: Boolean vector. Consideration of rows in the likelihood calculation, FALSE to exclude. Length equal to the number of observations (nObs). Default is "all"
, equivalent to rep(TRUE, nObs)
.
"componentName"
: Character. Name given to model component.
Character. Can take different values depending on desired output.
"estimate"
: Used for model estimation.
"prediction"
: Used for model predictions.
"validate"
: Used for validating input.
"zero_LL"
: Used for calculating null likelihood.
"conditionals"
: Used for calculating conditionals.
"output"
: Used for preparing output after model estimation.
"raw"
: Used for debugging.
The returned object depends on the value of argument functionality
as follows.
"estimate"
: vector/matrix/array. Returns the probabilities for the chosen alternative for each observation.
"prediction"
: Not applicable (NA
).
"validate"
: Same as "estimate"
"zero_LL"
: vector/matrix/array. Returns the probability of the chosen alternative when all parameters are zero.
"conditionals"
: Same as "estimate"
"output"
: Same as "estimate"
but also writes summary of input data to internal Apollo log.
"raw"
: Same as "estimate"