贝叶斯模型的 R-squared
现在让我们为一个贝叶斯模型计算 R-squared,以评估使用 stan_glm 估计的模型的预测表现。stan_model 对象已加载。
本练习是课程的一部分
使用 rstanarm 进行贝叶斯回归建模
练习说明
- 计算
stan_model残差的方差 - 计算
stan_model拟合值的方差 - 计算 R-squared
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Save the variance of residulas
ss_res <- ___(___(stan_model))
# Save the variance of fitted values
ss_fit <- ___(___(stan_model))
# Calculate the R-squared
1 - (___ / (___ + ___))