預測巧克力棒的占比
假設一家商店打算販售 Ghiradelli 的 5 種巧克力。這五款巧克力之間的占比會是什麼?商店可能需要這項資訊來規劃庫存,或調整陳列讓最受歡迎的種類更顯眼。
chocolate 資料集已為你預先載入,型別為 mlogit.data 物件。
本練習屬於課程
R 的行銷選擇模型
練習說明
- 使用
mlogit擬合choc_m2模型。第一個輸入為公式Selection ~ 0 + Brand + Type + Price,第二個輸入為data = chocolate。 - 建立一個資料框,包含 5 根巧克力棒,品牌都為
Ghirardelli,價格都為 $3。種類應為chocolate資料中測試過的五種類型。我已為你寫好開頭程式碼,你只需要完成價格的設定。 - 使用已載入的
predict_mnl()函式來預測占比。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# 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