將 Price 設為類別
就像我在上一支影片提到的,價格可以當成類別變數來處理。讓我們估計一個這樣的模型。chocolate 資料已經載入。
本練習屬於課程
R 的行銷選擇模型
練習說明
- 將
chocolate資料中的Price變數改為類別(factor)。 - 使用
mlogit,以Selection ~ 0 + Brand + Type + Price這個公式,對 chocolate 資料擬合模型,並指定給choc_m3。 - 使用
summary()檢視模型係數。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# change the Price variable to a factor in the chocolate data
# fit a model with mlogit and assign it to choc_m3
# inspect the coefficients