Get startedGet started for free

Predict shares for chocolate bars

Suppose a store plans to carry Ghiradelli chocolate in all 5 types. What will the shares be between these five chocolates? The store may want to know this so that they can plan their inventory or re-arrange the display to feature the most popular chocolate types.

The chocolate dataset is pre-loaded for you as an mlogit.data object.

This exercise is part of the course

Choice Modeling for Marketing in R

View Course

Exercise instructions

  • Fit the choc_m2 model using mlogit. The first input should be the formula Selection ~ 0 + Brand + Type + Price and the second should be data = chocolate.
  • Create a data frame that includes 5 chocolate bars that are all Ghirardelli and all priced at $3. The types should be the five types that were tested in the chocolate data. I've started the code for you. You just need to finish defining the prices.
  • Predict shares using my predict_mnl() function, which is already loaded.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# fit the choc_m2 model


# create a data frame with the Ghiradelli products
Brand <- factor(rep("Ghirardelli", 5), level = levels(chocolate$Brand))
Type <- levels(chocolate$Type)
Price <- _____   # treated as a number in choc_m2
ghir_choc <- data.frame(Brand, Type, Price)

# predict shares
Edit and Run Code