Simple Linear Regression - R-squared Visualization

Simple Linear Regression - R-squared Visualization
Loading the math board and drawing, please wait…
2020-01-17 13:04
① This GeoGebra example demonstrates the geometric meaning of R-squared (coefficient of determination) in simple linear regression, showing how data points relate to the fitted line. ② Core mathematical concepts include linear regression, least squares, Pearson correlation coefficient (PMCC), covariance, sample standard deviation, and the calculation and interpretation of R-squared. ③ Construction highlights: uses GeoGebra commands such as FitLineY to generate the best-fit line, SumSquaredErrors for residual sum of squares, and RSquare for the coefficient of determination; also constructs mean points, data points, residual vectors, and uses sliders or text to display dynamic values. ④ Suitable for high school and university statistics or data analysis courses, helping students understand the goodness of fit of regression models, and can be used for classroom demonstrations or self-directed exploration.

GeoGebra Commands & Parameters

  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