计算频率学派的 R-squared
来练习计算 R-squared。先从频率学派的 R-squared 入手,您可以手工推导公式并与频率学派摘要中的数值对照,核对是否一致。lm_model 和 lm_summary 对象已在您的环境中。
本练习是课程的一部分
使用 rstanarm 进行贝叶斯回归建模
练习说明
- 从
lm_summary对象中打印 R-squared 的数值 - 计算
lm_model残差的方差 - 计算
lm_model预测值的方差 - 计算 R-squared 的数值
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Print the R-squared from the linear model
lm_summary$___
# Calulate sums of squares
ss_res <- ___(___(lm_model))
ss_fit <- ___(___(lm_model))
# Calculate the R-squared
1 - (___ / (___ + ___))