開始使用免費開始

計算 LOO 估計值

現在來練習在 Spotify 模型上使用 loo 套件,以判斷哪一個模型最符合資料。songs 資料集已經載入。

本練習屬於課程

使用 rstanarm 的貝葉斯迴歸建模

檢視課程

練習說明

  • 估計一個以 song_age 預測 popularity 的模型
  • 列印這個僅含 1 個預測變數之模型的 LOO 近似值
  • 估計一個以 song_ageartist_name 及其交互作用預測 popularity 的模型
  • 列印這個含 2 個自變數之模型的 LOO 近似值

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Estimate the model with 1 predictor
model_1pred <- ___(___ ~ ___, data = songs)

# Print the LOO estimate for the 1 predictor model
___(model_1pred)

# Estimate the model with both predictors
model_2pred <- ___(___ ~ ___ * ___, data = songs)

# Print the LOO estimates for the 2 predictor model
___(model_2pred)
編輯並執行程式碼