Learn R Programming

logitr (version 0.2.0)

predictProbs: Predict expected choice probabilities

Description

Returns the expected choice probabilities for a single set or multiple sets of alternatives based on the results from an estimated model.

Usage

predictProbs(
  model,
  alts,
  obsIDName = NULL,
  computeCI = TRUE,
  alpha = 0.025,
  numDraws = 10^4
)

Arguments

model

The output of a model estimated model using the logitr() function.

alts

A data frame of a set of alternatives for which to predict choice probabilities. Each row is an alternative and each column an attribute corresponding to parameter names in the estimated model.

obsIDName

The name of the column that identifies each set of alternatives. Required if simulating results for more than one set of alternatives. Defaults to NULL (for a single set of alternatives).

computeCI

Should a confidence interval be computed? Defaults to TRUE.

alpha

The sensitivity of the computed confidence interval. Defaults to alpha = 0.025, reflecting a 95% CI.

numDraws

The number of draws to use in simulating uncertainty for the computed confidence interval.

Value

A data frame with the estimated choice probabilities for each alternative in alts.

Examples

Run this code
# NOT RUN {
# Run a MNL model in the Preference Space:
library(logitr)

mnl_pref <- logitr(
  data = yogurt,
  choiceName = "choice",
  obsIDName = "obsID",
  parNames = c("price", "feat", "brand")
)

# Create a set of alternatives for which to predict choice probabilities.
# Each row is an alternative and each column an attribute.
# In this example, I just use two of the choice observations from the
# yogurt dataset:
alts <- subset(yogurt, obsID %in% c(42, 13),
               select = c('obsID', 'price', 'feat', 'brand'))
alts

# Predict choice probabilities using the estimated preference space MNL
# model:
predictProbs(mnl_pref, alts, obsIDName = "obsID")
# }

Run the code above in your browser using DataLab