Learn R Programming

apollo (version 0.0.8)

apollo_ol: Calculates the probability of an ordered logit model

Description

Calculates the probabilities of an ordered logit model and can also perform other operations based on the value of the functionality argument.

Usage

apollo_ol(ol_settings, functionality)

Arguments

ol_settings

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

Numeric vector. Thresholds. As many as number of different levels in the dependent variable - 1. Extreme thresholds are fixed at -inf and +inf. No mixing 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 V, 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.

functionality

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.

Value

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. Returns a list with the probabilities for each possible outcome.

"validate"

Boolean. Returns TRUE if all tests are passed.

"zero_LL"

vector/matrix/array. Returns the probability of the chosen alternative when all parameters are zero.

"conditionals"

Same as "prediction".

"output"

Same as "estimate" but also writes summary of choices into temporary file (later read by apollo_modelOutput).

"raw"

Same as "prediction".

Details

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.