Regression & R²
About this app
Least-squares line on lecture data: errors as squares, SST = SSR + SSE as a right triangle, SSE as a bowl over slope and position; Anscombe, a parabola and a confounder show what R² does not reveal.
What R² measures
The least squares line ŷ = a + b·x makes the sum of squared vertical distances SSE = Σ(yᵢ − ŷᵢ)² as small as possible. For this line the total variation SST = Σ(yᵢ − ȳ)² splits into the explained variation SSR = Σ(ŷᵢ − ȳ)² and the unexplained SSE: SST = SSR + SSE. The coefficient of determination R² = SSR / SST is the explained share; in simple linear regression R² = r². R² measures the strength of a linear relationship, not the slope, and not whether a straight line is the right model at all.
What you see
Four cards show the same regression from different angles: the data with line and squared errors, the decomposition of variation as a right triangle built from the squares SST, SSR and SSE, the residual plot, and the error surface SSE over slope and position of the line. Data sets include a DC motor and mortgage rates from a lecture, edge cases such as “Exactly linear”, “Parabola”, “Flat, tight” and “Steep, scattered”, Anscombe’s quartet with R² ≈ 0.67, and a firefighter example with a confounder.
Things to try
Turn on your own line, tilt and shift it: the error sum rises, and in the triangle SSR + SSE no longer equals SST. Compare the four Anscombe data sets in the residual plot even though their R² is almost identical. Change the unit of y: SSE changes, R² stays. In the firefighter data, damage falls with more firefighters within each group, yet the overall line rises. The prediction tool reads off ŷ for a new x.
Frequently asked questions
- What does R squared mean?
- R² is the share of the variation in y that the regression line explains. It lies between 0 and 1 and, in simple linear regression, equals the square of the correlation coefficient r. An R² of 0.8 means that 80 % of the total variation SST is explained.
- What is the difference between SST, SSR and SSE?
- SST is the total variation of the y values around their mean, SSR the variation explained by the line, and SSE the sum of squared residuals. For the least squares line, SST = SSR + SSE. It follows that R² = SSR / SST = 1 − SSE / SST.
- Can a high R² be misleading?
- Yes. Anscombe’s quartet consists of four data sets with nearly the same R², only one of which is linear. A high R² can also be produced by a confounding variable and does not prove cause and effect. Conversely, an exact but nonlinear relationship such as a symmetric parabola can give R² = 0.
- What can I try in this app?
- You pick one of eleven data sets, drag or add points, and try your own line, also directly on the error surface. Residuals, centroid, variation strips and the x-on-y line can be shown. A prediction gives ŷ for an unobserved x.
Subject: Probability & statistics
More from Probability & statistics
- Curve-fitting playground
- Galton board
- Covariance & Regression
- Covariance & regression 2.0
- Coin flips: law of large numbers
- Spray a Point Cloud
- Monty Hall problem
A VisuApp by heyprof: interactive, free in your browser, no sign-up. What is a VisuApp? · All apps