Learn R Programming

apollo (version 0.1.0)

apollo_lc: Calculates the likelihood of a latent class model

Description

Using the conditional likelihoods of each latent class, as well as teir classification probabilities, calculate the weighted likelihood of the whole model.

Usage

apollo_lc(lc_settings, apollo_inputs, functionality)

Arguments

lc_settings

List of arguments used by apollo_lc. It must include the following.

  • inClassProb: List of probabilities. Conditional likelihood for each class. One element per class, in the same order as classProb.

  • classProb: List of probabilities. Allocation probability for each class. One element per class, in the same order as inClassProb.

  • componentName: Character. Name given to model component.

apollo_inputs

List grouping most common inputs. Created by function apollo_validateInputs.

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 of vectors/matrices/arrays. Returns a list with the probabilities for all models components, for each class.

  • "validate": Same as "estimate", but also runs a set of tests on the given arguments.

  • "zero_LL": Same as "estimate"

  • "conditionals": Same as "estimate"

  • "output": Same as "estimate" but also writes summary of input data to internal Apollo log.

  • "raw": Same as "prediction"

Examples

Run this code
# NOT RUN {
data(apollo_modeChoiceData)
database <- apollo_modeChoiceData
rm(apollo_modeChoiceData)
N <- nrow(database)
lc_settings <- list(inClassProb=list(rnorm(N), rnorm(N)),
                    classProb=list(stats::runif(N), stats::runif(N)))
apollo_control <- list(indivID="ID")
x <- apollo_lc(lc_settings, apollo_control, functionality="estimate")
summary(x)
# }

Run the code above in your browser using DataLab