開始使用免費開始

將 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
編輯並執行程式碼