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 Multinomial 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. Use value -1 if a stage does not apply for a given observations (e.g. when some individuals have shorter rankings).
"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. 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.
"shares_LL": Used for calculating likelihood with constants only.
"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.
"shares_LL": Not implemented. Returns a vector of NA with as many elements as observations.
"conditionals": Same as "estimate"
"output": Same as "estimate" but also writes summary of input data to internal Apollo log.
"raw": Same as "estimate"