開始使用免費開始

為巧克力棒預測市佔

假設商店打算銷售 Ghirardelli 的 5 種口味。這 5 種巧克力之間的市佔會是什麼樣子?商店可能想先掌握這點,好規劃庫存,或調整陳列以凸顯最受歡迎的口味。

chocolate 資料集已為你預先載入,型別為 dfidx 物件。

本練習屬於課程

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 Ghirardelli products
Brand <- factor(rep("Ghirardelli", 5), levels = levels(chocolate$Brand))
Type <- levels(chocolate$Type)
Price <- _____   # treated as a number in choc_m2
ghir_choc <- data.frame(Brand, Type, Price)

# predict shares
編輯並執行程式碼