Learn R Programming

apollo (version 0.0.1)

apollo_avgInterDraws: Averages inter-individual draws

Description

Averages the likelihood across inter-individual draws.

Usage

apollo_avgInterDraws(P, apollo_control, functionality, indivID)

Arguments

P

List. Contains the probabilities for each model component, for each inter-person draw. Intra-person draws must have been averaged over on P, before giving it as an argument to this function.

apollo_control

List. Contains options for the estimation See apollo_validatecontrol for details.

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 getting null likelihood.

"conditionals"

Used for getting conditionals.

"output"

Used for preparing output after model estimation.

"raw"

Used for debugging.

indivID

Numeric vector. Vector with individual's ID. As long as the number of observations.

Value

Average probability over inter-individual draws (shape depends on argument functionality).

"estimate"

Returns P averaged across inter-individual draws for the chosen alternative.

"prediction"

Returns P averaged across inter-individual draws for all alternatives.

"validate"

Returns P without changes.

"zero_LL"

Returns P without changes.

"conditionals"

Returns P without changes, but checks its shape.

"output"

Returns the same than "estimate", but also prints a summary of estimation data.

"raw"

Returns P without changes.

Details

This function performs additional checks on the shape of the probabilities given as arguments. The shape of P should be consistent with the value of functionality, but compliance is assured if P comes from apollo_mnl. For functionality values of "estimate", "zero_LL, "conditionals" and "output", P should be a list of matrices, with each matrix containing the likelihood of the chosen alternative. For functionality values of "prediction" and "raw", P should be a list, with each of its elements a list of matrices, and each matrix containing the likelihood of a different alternative. For the functionality value of "validate", P can be anything, as it is not processed.