Linear Regression: Drag Points or Input Data to Fit a Line

Linear Regression: Drag Points or Input Data to Fit a Line
Loading the math board and drawing, please wait…
2014-05-12 22:26
In collections ggbchat #4 July 16 2014
① This example demonstrates how users can define data points by dragging dots or manually entering/modifying them in a spreadsheet, and then observe the fitted linear regression line along with key statistical outputs. ② Core mathematical concepts include least-squares linear regression, residuals, coefficient of determination (R²), sample standard deviation, median, and the equation of the fitted line, as well as intersections between geometric objects. ③ Construction highlights: The GeoGebra command FitLineY computes the regression line, Line draws it, Intersect finds intersection points, Polygon and Vector help visualize data ranges or residual vectors, RSquare and SampleSD calculate statistical measures, Text displays results, Circle may represent confidence intervals or error circles, and data points are managed via spreadsheet objects (A1-A20) and the list list_x. ④ Suitable for high school to undergraduate statistics and data analysis courses, as well as math lab sessions, to deepen understanding of regression analysis and its parameters.

GeoGebra Commands & Parameters

  1. Line(U, V) → line_{guess}
  2. Line(A, x = 0) → a
  3. Line(B, x = 0) → b
  4. Line(C, x = 0) → c
  5. Line(D, x = 0) → d
  6. Line(E, x = 0) → e
  7. Line(F, x = 0) → f
  8. Line(G, x = 0) → g
  9. Line(H, x = 0) → h
  10. Line(I, x = 0) → i
  11. Line(J, x = 0) → j
  12. Line(K, x = 0) → k
  13. Line(L, x = 0) → l
  14. Line(M, x = 0) → m
  15. Line(N, x = 0) → n
  16. Line(NP, x = 0) → np
  17. Line(O, x = 0) → p
  18. Line(P, x = 0) → q
  19. Line(R, x = 0) → s
  20. Line(S, x = 0) → t
  21. Intersect(line_{guess}, a) → A'
  22. Intersect(line_{guess}, b) → B'
  23. Intersect(line_{guess}, c) → C'
  24. Intersect(line_{guess}, d) → D'
  25. Intersect(line_{guess}, e) → E'
  26. Intersect(line_{guess}, f) → F'
  27. Intersect(line_{guess}, g) → G'
  28. Intersect(line_{guess}, h) → H'
  29. Intersect(line_{guess}, i) → I'
  30. Intersect(line_{guess}, j) → J'
  31. Intersect(line_{guess}, k) → K'
  32. Intersect(line_{guess}, l) → L'
  33. Intersect(line_{guess}, m) → M'
  34. Intersect(line_{guess}, n) → N'
  35. Intersect(line_{guess}, np) → NP'
  36. Intersect(line_{guess}, p) → O'
  37. Intersect(line_{guess}, q) → P'
  38. Intersect(line_{guess}, s) → R'
  39. Intersect(line_{guess}, t) → S'
  40. Line(Q, x = 0) → r
  41. Intersect(line_{guess}, r) → Q'
  42. Polygon(A', A, 4) → poly1, a_1, b_1, c_1, d_1, T, W
  43. Polygon(B', B, 4) → poly2, e_1, f_1, g_1, h_1, Z, A_1
  44. Polygon(D', D, 4) → poly3, i_1, j_1, k_1, l_1, B_1, C_1
  45. Polygon(E', E, 4) → poly4, m_1, n_1, p_1, q_1, D_1, E_1
  46. Polygon(C', C, 4) → poly5, r_1, s_1, t_1, a_2, F_1, G_1
  47. Polygon(F', F, 4) → poly6, b_2, c_2, d_2, e_2, H_1, I_1
  48. Polygon(G', G, 4) → poly7, f_2, g_2, h_2, i_2, J_1, K_1
  49. Polygon(H', H, 4) → poly8, j_2, k_2, l_2, m_2, L_1, M_1
  50. Polygon(I', I, 4) → poly9, n_2, p_2, q_2, r_2, N_1, O_1
  51. Polygon(J', J, 4) → poly10, s_2, t_2, a_3, b_3, P_1, Q_1
  52. Polygon(K', K, 4) → poly11, c_3, d_3, e_3, f_3, R_1, S_1
  53. Polygon(L', L, 4) → poly12, g_3, h_3, i_3, j_3, T_1, U_1
  54. Polygon(M', M, 4) → poly13, k_3, l_3, m_3, n_3, V_1, W_1
  55. Polygon(N', N, 4) → poly14, p_3, q_3, r_3, s_3, Z_1, A_2
  56. Polygon(NP', NP, 4) → poly15, t_3, a_4, b_4, c_4, B_2, C_2
  57. Polygon(P', P, 4) → poly16, d_4, e_4, f_4, g_4, D_2, E_2
  58. Polygon(O', O, 4) → poly17, h_4, i_4, j_4, k_4, F_2, G_2
  59. Polygon(Q', Q, 4) → poly18, l_4, m_4, n_4, p_4, H_2, I_2
  60. Polygon(R', R, 4) → poly19, q_4, r_4, s_4, t_4, J_2, K_2
  61. Polygon(S', S, 4) → poly20, a_5, b_5, c_5, d_5, L_2, M_2
  62. Vector((x(A), 0), (x(A), y(A) - y(A'))) → V_A
  63. Vector((x(B), 0), (x(B), y(B) - y(B'))) → V_B
  64. Vector((x(C), 0), (x(C), y(C) - y(C'))) → V_C
  65. Vector((x(D), 0), (x(D), y(D) - y(D'))) → V_D
  66. Vector((x(E), 0), (x(E), y(E) - y(E'))) → V_E
  67. Vector((x(F), 0), (x(F), y(F) - y(F'))) → V_F
  68. Vector((x(G), 0), (x(G), y(G) - y(G'))) → V_G
  69. Vector((x(H), 0), (x(H), y(H) - y(H'))) → V_H
  70. Vector((x(I), 0), (x(I), y(I) - y(I'))) → V_I
  71. Vector((x(J), 0), (x(J), y(J) - y(J'))) → V_J
  72. Vector((x(K), 0), (x(K), y(K) - y(K'))) → V_K
  73. Vector((x(L), 0), (x(L), y(L) - y(L'))) → V_L
  74. Vector((x(M), 0), (x(M), y(M) - y(M'))) → V_M
  75. Vector((x(N), 0), (x(N), y(N) - y(N'))) → V_N
  76. Vector((x(NP), 0), (x(NP), y(NP) - y(NP'))) → V_{NP}
  77. Vector((x(P), 0), (x(P), y(P) - y(P'))) → V_P
  78. Vector((x(Q), 0), (x(Q), y(Q) - y(Q'))) → V_Q
  79. Vector((x(R), 0), (x(R), y(R) - y(R'))) → V_R
  80. Vector((x(O), 0), (x(O), y(O) - y(O'))) → V_O
  81. Vector((x(S), 0), (x(S), y(S) - y(S'))) → V_S
  82. RSquare(data, line_{guess}) → Strength
  83. SampleSD(list_y) → SD_y
  84. Median(list_x) → Median_x
  85. Vector((Median_x / 2, (SD_y * 2)), (Median_x / 2, (SD_y * 2) + over)) → Vector_{over}
  86. Vector((Median_x / 2, (SD_y * 2)), (Median_x / 2, (SD_y * 2) - under)) → Vector_{under}
  87. Text(((Strength * 100) * "%"), ((Median_x * 1.425), (SD_y * 1.95))) → text1
  88. FitLineY(data) → line_{actual}
  89. Circle(((Median_x * 1.5), (2 * SD_y)), (Strength * Max[list_y] / 6)) → g_5
  90. Circle(((Median_x * 1.5), (2 * SD_y)), (Strength * Max[list_y] / 6)) → CorrelationCircle
  91. Circle(((Median_x * 1.5), (2 * SD_y)), (Strength * Max[list_y] / 6)) → CorrelationCircle_1
  92. Circle(((Median_x * 1.5), (2 * SD_y)), (Strength * Max[list_y] / 6)) → f_5

AI Drawing Prompt Reference

Create a scatter plot with data points, each connected by a vertical line to a draggable fitted line, forming residual rectangles. The fitted line is defined by two movable points, and data points can be edited in a table. Display the regression equation, R-squared, sample standard deviation, and other statistics, with residual rectangles in distinct colors.
The prompt above was compiled from the original drawing commands and is for reference only.