简单线性回归与R平方的可视化演示

简单线性回归与R平方的可视化演示
几何画板及绘图内容加载中,请稍等……
2020-01-17 13:04
① 本范例通过GeoGebra动态展示简单线性回归中R平方(决定系数)的几何意义,直观呈现数据点与拟合直线之间的关系。② 核心数学概念包括线性回归、最小二乘法、相关系数(PMCC)、协方差、样本标准差以及R平方的计算与解释。③ 作图要点:利用GeoGebra的FitLineY命令生成最佳拟合直线,通过SumSquaredErrors计算残差平方和,使用RSquare得到决定系数;同时构造均值点、数据点、残差向量等对象,并借助滑块或文本显示动态数值变化。④ 适合高中及大学统计学、数据分析课程,用于帮助学生理解回归模型的拟合优度,也可作为教师课堂演示或学生自主探究的素材。

GeoGebra 命令及参数

  1. Length(DataPoints) → SampleSize
  2. mean(DataX) → MeanX
  3. mean(DataY) → MeanY
  4. Zip(Vector[(x(A), MeanY), A], A, DataPoints) → FromMeanX
  5. Zip(Vector[(MeanX, y(A)), A], A, DataPoints) → FromMeanY
  6. PMCC(DataPoints) → CorrelationXY
  7. SampleSDX(DataPoints) → SX
  8. SampleSDY(DataPoints) → SY
  9. Zip(Point[{A, B}], A, XZ, B, YZ) → DataPointsZ
  10. Zip(Vector[(x(A), 0), A], A, DataPointsZ) → FromMeanXZ
  11. Zip(Vector[(0, y(A)), A], A, DataPointsZ) → FromMeanYZ
  12. Point(yAxis) → UserPointA
  13. Line(UserPointA, UserPointB) → YourLine
  14. Slope(YourLine) → UserSlope
  15. Sum((DataY - UserPredictedY)^(2)) → UserSSResidual
  16. Vector(UserParameters, (UserIntercept, UserSlope, UserSSResidual)) → u
  17. FitLineY(DataPoints) → f
  18. Slope(f) → OLSSlope
  19. SumSquaredErrors(DataPoints, f) → OLSSSResidual
  20. Vector(OLSParameters, (OLSIntercept, OLSSlope, OLSSSResidual)) → v
  21. RSquare(DataPoints, f) → OLSRsq
  22. RSquare(DataPoints, YourLine) → UserRsq
  23. SumSquaredErrors(DataPoints, MeanOnly) → TotalSSResidual
  24. Zip(Vector[(x(A), YourLine(A)), A], A, DataPoints) → UserResidualVector
  25. Zip(Vector[(x(A), f(A)), A], A, DataPoints) → OLSResidualVector
  26. Vector((1, 0), (1, TotalSSResidual)) → VectorTotalSSR
  27. Vector((2, 0), (2, OLSSSResidual)) → VectorOLSSSR
  28. Vector((2, TotalSSResidual), (2, OLSSSResidual)) → VectorModelSSR
  29. Zip(Vector[(x(A) + MDisplace, MeanY), (x(A) + MDisplace, y(A))], A, DataPoints) → MeanResidualVector