为巧克力棒预测占比
假设一家商店计划同时售卖 Ghirardelli 的 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