R-Squared Calculator

Calculate R-squared (coefficient of determination) from x and y data pairs.
Returns the regression line, correlation coefficient, and goodness-of-fit.

R-Squared

R-squared (R²) measures the proportion of variance in y that is explained by the linear regression on x. An R² of 1.0 means the regression line passes through every data point perfectly. An R² of 0 means the line explains none of the variance — knowing x tells you nothing useful about y.

The calculation uses ordinary least squares. First, fit a line y = mx + b that minimizes the sum of squared vertical distances from each point to the line. Then:

R² = 1 - SS_res / SS_tot

where SS_res is the sum of squared residuals (actual minus predicted), and SS_tot is the total sum of squares (actual minus mean).

R² is the square of the Pearson correlation coefficient r. A perfect positive correlation (r=1) gives R²=1. A perfect negative correlation (r=-1) also gives R²=1, because R² measures explanation, not direction.

Equivalently: R² = [n·Σ(xy) - Σx·Σy]² / [(n·Σx² - (Σx)²) · (n·Σy² - (Σy)²)]

What counts as a “good” R²? It depends heavily on the field. Physical experiments routinely achieve R² > 0.99. Economic and social science data may show R² of 0.3-0.5 and still be meaningful. High R² does not prove causation — a perfectly correlated spurious relationship has R² = 1.

Residuals matter as much as R². Plot your data (the chart shows the points and regression line). If the residuals form a curve rather than a random scatter, a linear model is the wrong choice regardless of what R² says.


How we build and check this calculator

This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.

SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.

Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.