Lelifi·tools

Coefficient of Determination Calculator

Six students studying 1 to 6 hours score 52 to 74 points, and study time explains 99.25 percent of the variance in scores. That is an R squared of 0.9925, computed as 1 - 2.70 / 359.33. Enter paired x and y lists and the tool returns R squared, the correlation r and the least squares line.

Paste or type two lists of paired values, separated by commas, spaces or new lines. The first list is the x values and the second is the matching y values, in the same order.

Paste two matching lists of x and y values and get the coefficient of determination R squared, the correlation r, and the slope and intercept of the least squares line.

By the Lelifi editors ·

Key takeaways

Study hours against test scorescorehours studiedscore = 46.87 + 4.5143 x hoursThe points hug the line, so R squared lands at 0.9925.
Six study-and-score pairs with the least squares line score = 46.87 + 4.5143 x hours. The points hug the line, so R squared lands at 0.9925.
Splitting the total varianceTotal, SStotal = 359.33Explained by the line, 356.63Left over, SSresidual = 2.70R squared = 1 - 2.70 / 359.33 = 0.9925: the green band is 99.25 percent of the total.
The total sum of squares, 359.33, splits into 356.63 that the line explains and 2.70 that it misses. The leftover share against the total sets R squared at 1 - 2.70 / 359.33 = 0.9925.
On this page
  1. What the coefficient of determination measures
  2. Two formulas that give the same number
  3. A full worked example, six students
  4. Reading an R squared value
  5. R squared against the correlation r
  6. What R squared does not tell you
  7. Reporting it with the regression line
  8. From R squared to prediction quality

What the coefficient of determination measures

The coefficient of determination, written R squared or R2, answers one question: of all the up-and-down variation in the y values, how much does the fitted line account for? A value of 0.80 says 80 percent of the variance sits on the line and 20 percent scatters around it. A value of 0.00 says the line explains none of it, no better than guessing the average y for every point.

Statisticians frame it as a comparison of two errors. Predict every response with the mean of y and you rack up the total sum of squares, SStotal. Predict with the regression line instead and the leftover error shrinks to SSresidual. R squared is the share of that error the line removed: R2 = 1 - SSresidual / SStotal.

It is a goodness of fit number for least squares regression, not a correlation and not a proof that x causes y. The NIST/SEMATECH e-Handbook section on least squares presents it in exactly that role, as a way to judge a fitted line.

An error framing helps some readers. Suppose you had to guess every student's score with no information at all; the best available guess is the class mean, and your typical miss is measured by SStotal. Handing you the study hours and the fitted line cuts that miss down to SSresidual. R squared reports the size of the cut, so it can be read as how much the one variable bought you, from nothing at 0 to everything at 1.

Two formulas that give the same number

For a simple regression with one x variable there are two routes to the same value. The variance route uses the sums of squares. The correlation route squares the Pearson correlation r. Both give 0.9925 for the worked example below.

QuantityFormulaWhat it is
SStotalsum of (y - y mean) squaredtotal spread of y around its mean
SSresidualsum of (y - yhat) squaredwhat the line leaves behind
R squared1 - SSresidual / SStotalshare of the variance explained
rPearson correlationdirection and tightness, from -1 to 1
R squared, one predictorr x rthe same number by the second route

With more than one predictor the two routes part ways, and the variance definition is the one to use. Multiple R squared never drops when you add a predictor, which is why the adjusted version exists; this page sticks to the one-variable case, where the number is unambiguous.

Either route needs the raw pairs. With only a published r and no data, squaring it gives the one-predictor R squared on the spot, but SStotal and SSresidual cannot be recovered without the points themselves, so the two formulas are complements rather than substitutes: the sums of squares come from the data, and the squared correlation is a shortcut that works only when a single x is in the model.

A full worked example, six students

Six students log 1, 2, 3, 4, 5 and 6 hours of study and score 52, 55, 61, 64, 70 and 74 points on a test. The means are 3.5 hours and 62.67 points. Least squares gives the line score = 46.87 + 4.5143 x hours, where the slope comes from 79 / 17.5 = 4.5143 and the intercept from 62.67 - 4.5143 x 3.5 = 46.87.

Hours xScore yPredicted yhatResidual
15251.380.62
25555.90-0.90
36160.410.59
46464.92-0.92
57069.440.56
67473.950.05

Squaring each residual and adding the six squares gives SSresidual = 2.70. The total sum of squares around the mean of 62.67 comes to SStotal = 359.33. The coefficient of determination is 1 - 2.70 / 359.33 = 0.9925: study time accounts for 99.25 percent of the variance in scores, and 0.75 percent is left to sleep, luck and everything else. Residuals are shown rounded to two decimals, so their squares do not recompute exactly from the rounded column.

Reading an R squared value

A coefficient of determination is a share, running from 0 to 1 in the one-predictor case, and it carries no units. What counts as strong depends entirely on the setting, which is why the number should travel with context rather than a fixed grading scale.

Correlation rR squaredVariance explained
0.90.8181 percent
0.70.4949 percent
0.50.2525 percent
0.30.099 percent
0.10.011 percent

The table shows how misleading a correlation can be on its own. A correlation of 0.5 sounds middling to decent, yet the line explains only 0.5 x 0.5 = 0.25 of the variance, one quarter. In lab calibration work an R squared above 0.99 is routine; in studies of human behavior 0.25 can be a real finding. Compare against the norm for your kind of data, not in the abstract.

Field context cuts both ways. A 0.49 from a 0.7 correlation is excellent for guessing whether rain is coming from a rising barometer but weak for predicting a metal part's length from its temperature in a controlled shop, and the same number printed next to a different dataset deserves a different verdict. The statistic is one input to that judgment, not the judgment itself.

R squared against the correlation r

For one predictor, R squared is exactly r squared, so the two carry the same information about fit. The differences are still worth knowing. The correlation keeps its sign: r = -0.9 for a strong downward trend and r = 0.9 upward both give R squared = 0.81, so the coefficient of determination alone cannot tell you which way the line slopes. The correlation is also the one with a direct visual reading, while the squared version is the one that says how much variance moved onto the line.

The student data checks out both ways: r = 0.99623, and 0.99623 x 0.99623 = 0.9925, matching the variance route to four decimals.

What R squared does not tell you

Three blind spots come up again and again. First, fit is not causation. Ice cream sales and drowning counts track each other through summer heat, and a high R squared would happily sit on top of that pairing without a causal link between the two.

Second, the number says nothing about the shape of the trend. A curved relationship scored against a straight line can still post a respectable R squared, which is why a picture belongs next to any regression; the scatter plot and the Boston University statistics module on correlation and regression both make that case with examples.

Third, one outlier can move the value a long way on its own. A single wild point at the edge of the x range can drag the slope and either inflate or sink R squared, so read the residual column before trusting the headline number. And when predictors are added one after another, R squared can only stay flat or climb, never fall, even if the new variable is noise; that gap is what the adjusted R squared fills in multiple regression.

Reporting it with the regression line

On its own, R squared says how much variance sits on the line, which is why it is normally reported beside the line itself. The student example reads naturally as a sentence: scores rise 4.51 points per study hour on the fitted line, and an R squared of 0.9925 says the line tracks nearly all of the variation across the six students. The slope and intercept give the predictions, R squared gives the trust you can put in them, and the residual column shows where that trust runs out.

Being unitless, the statistic compares across models that predict different things. A 0.6 from speed against braking distance and a 0.6 from salary against years of experience mean the same thing, a 60 percent variance share, even though one predicts meters per second and the other dollars. For the spread of a single variable with no predictor at all, the variance calculator and the standard deviation calculator handle the SStotal starting point, and the statistics calculator covers the summary stats around it.

A short reporting template keeps the trio straight: state the line, then R squared, then the residual scale. Written out, the example becomes score = 46.87 + 4.5143 x hours, R squared = 0.9925, with residuals of a point or less across the six students. Anyone reading that sentence gets the prediction rule, the variance share and the typical miss in one pass.

From R squared to prediction quality

R squared describes the line, but predictions carry their own yardstick, the standard error of the estimate. It comes from the same leftover sum: take SSresidual, divide by the degrees of freedom, n - 2 for a straight line, and take the square root. For the student example, 2.70 / 4 = 0.675, and the square root of 0.675 is about 0.82, so individual scores typically land within roughly 0.82 points of the line's prediction.

The two numbers answer different questions and work best as a pair. R squared says how much of the pattern the hours explain; the standard error says how far off a single prediction will usually be, in the units of y. A model can post a strong R squared and still be of little use for individual calls if the y values span a huge range, and a modest R squared can support workable predictions when the leftover spread is small compared with what the decision needs.

Frequently asked questions

What does the coefficient of determination tell you?

The share of variance in y that a fitted regression line explains. An R squared of 0.80 means the line accounts for 80 percent of the up-and-down movement and 20 percent remains as residuals.

How do you calculate R squared?

Compute SStotal from the squared distances of every y from its mean, then SSresidual from the squared distances to the fitted line. In the six-student example, 1 - 2.70 / 359.33 = 0.9925.

What is a good R squared value?

It depends on the field. Lab calibration work often runs above 0.99, while 0.25 can be a solid result in studies of human behavior. Compare against the norm for your kind of data, not a fixed bar.

Is R squared the same as the correlation coefficient?

For one predictor, R squared equals r squared. A correlation of 0.5 gives 0.5 x 0.5 = 0.25, so a middling correlation explains only a quarter of the variance.

Can R squared be negative?

Not for a standard least squares line with an intercept, where it stays between 0 and 1. A negative value appears only in odd setups, such as a line forced through a fixed point that fits worse than the mean.

Why is my R squared high but the fit looks wrong?

A straight-line fit scores curved data this way. Plot the points first: a clear bend in the residuals with a high R squared is a sign the straight line is the wrong model.

What does an R squared of 0 mean?

The line explains none of the variance in y. Predicting with the regression line is no better than predicting every value with the mean of y.

How many data points do I need?

At least 3 before the statistic means much, and more is better. With the 6 paired points in the example above, an R squared of 0.9925 is informative, but small samples let a single point swing the value.

Does a high R squared prove that x causes y?

No. It measures fit only. Confounded pairs such as ice cream sales and drownings can post a high value with no causal link between them.

What is adjusted R squared?

A corrected version that penalizes adding predictors, since plain R squared never falls when a variable is added, even a useless one. It matters in multiple regression; with one predictor the two are close.

What is the difference between SSresidual and SStotal?

SStotal measures the spread of y around its mean, 359.33 in the worked example. SSresidual measures what remains after the line, 2.70 there. The ratio of the two sets R squared.

Can I use R squared for nonlinear models?

The variance share can be computed the same way, but many nonlinear fits report pseudo R squared values instead, and a straight-line R squared is not a valid fit measure for them.

Spotted a wrong number or a broken result?

More Math tools

See all Math tools

Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.