# 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