Learn R Programming

logitr (version 0.1.0)

simulateShares: Simulate expected shares from a set of alternatives

Description

Returns the expected shares of a specific set of alternatives based on an estimated model.

Usage

simulateShares(model, alts, priceName = NULL, alpha = 0.025)

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 simulate shares. Each row is an alternative and each column an attribute corresponding to parameter names in the estimated model.

priceName

The name of the parameter that identifies price. Only required for WTP space models. Defaults to NULL.

alpha

The sensitivity of the computed confidence interval, e.g. a 90% CI is obtained with alpha = 0.05. Defaults to alpha = 0.025.

Value

A data frame with the estimated shares 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", "dannon", "hiland", "yoplait")
)

# Create a set of alternatives for which to simulate shares:
alts <- subset(yogurt, obsID == 42,
  select = c("feat", "price", "dannon", "hiland", "yoplait")
)
row.names(alts) <- c("dannon", "hiland", "weight", "yoplait")
alts

# Run the simulation using the estimated preference space MNL model:
simulateShares(mnl_pref, alts)
# }

Run the code above in your browser using DataLab