开始使用免费开始使用

计算频率学派的 R-squared

来练习计算 R-squared。先从频率学派的 R-squared 入手,您可以手工推导公式并与频率学派摘要中的数值对照,核对是否一致。lm_modellm_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 - (___ / (___ + ___))
编辑并运行代码