Calculates the probabilities of an Ordered Logit model and can also perform other operations based on the value of the functionality
argument.
apollo_ol(ol_settings, functionality)
List of settings for the OL model. It should include the following.
outcomeOrdered
Numeric vector. Dependant variable. The coding of this variable is assumed to be from 1 to the maximum number of different levels. For example, if the ordered response has three possible values: "never", "sometimes" and "always", then it is assumed that outcomeOrdered contains "1" for "never", "2" for "sometimes", and 3 for "always". If another coding is used, then it should be specified using the coding
argument.
V
Numeric vector. A single explanatory variable (usually a latent variable). Must have the same number of rows as outcomeOrdered.
tau
List of numeric vector/matrix/3-dim arrays. Thresholds. As many elements as number of different levels in the dependent variable - 1. Extreme thresholds are fixed at -inf and +inf. Mixing is allowed in thresholds.
coding
Numeric or character vector. Optional argument. Defines the order of the levels in outcomeOrdered
. The first value is associated with the lowest level of outcomeOrdered
, and the last one with the highest value. If not provided, is assumed to be 1:(length(tau) + 1)
.
rows
Boolean vector. TRUE if a row must be considered in the calculations, FALSE if it must be excluded. It must have length equal to the length of argument outcomeOrdered
. Default value is "all"
, meaning all rows are considered in the calculation.
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"
: List of vectors/matrices/arrays. Returns a list with the probabilities for all possible levels, with an extra element for the probability of the chosen alternative.
"validate"
: Same as "estimate"
, but it also runs a set of tests to validate the function inputs.
"zero_LL"
: Not implemented. Returns a vector of NA with as many elements as observations.
"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 "prediction"
This function estimates an Ordered Logit model of the type:
y* = V + epsilon
outcomeOrdered = 1 if -Inf < y* < tau[1]
2 if tau[1] < y* < tau[2]
...
maxLvl if tau[length(tau)] < y* < +Inf
Where epsilon is distributed standard logistic, and the values 1, 2, ..., maxLvl can be
replaces by coding[1], coding[2], ..., coding[maxLvl].
The behaviour of the function changes depending on the value of the functionality
argument.