开始使用免费开始使用

计算 LOO 估计

现在请在我们的 Spotify 模型上练习使用 loo 包,以便判断哪个模型与数据的拟合最好。songs 数据集已加载。

本练习是课程的一部分

使用 rstanarm 进行贝叶斯回归建模

查看课程

练习说明

  • 拟合以 song_age 预测 popularity 的模型
  • 打印该单一自变量模型的 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)
编辑并运行代码