Predicting shares for the racer segment
Let's predict shares for a different sportscar segment. I've preloaded the m5
model and the predict_mnl()
function I showed you in the video. In the sample code, you will also see my code for creating the prod
data frame. Your task is to modify my code to predict shares for the "racer"
segment.
Diese Übung ist Teil des Kurses
Choice Modeling for Marketing in R
Anleitung zur Übung
- Modify my code for creating the
prod
data frame so thesegment
variable is"racer"
for both products. Remember that user variables likesegment
should be the same for all the products inprod
. - Predict shares for the products in
prod
using them5
model. You can use mypredict_mnl()
function to do this. Make sure the output indicates that thesegment
is"racer"
for both products.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# modify the code below so that the segement is set to "racer" for both alternatives
price <- c(35, 30)
seat <- factor(c(2, 2), levels=c(2,4,5))
trans <- factor(c("manual", "auto"), levels=c("auto", "manual"))
convert <- factor(c("no", "no"), levels=c("no", "yes"))
segment <- factor(c("basic", "basic"), levels=c("basic", "fun", "racer"))
prod <- data.frame(seat, trans, convert, price, segment)
# predict shares for the "racer" segment