Home›Math & Stats›Coefficient of determination
Coefficient of Determination Calculator
Your data
Separate values with commas, spaces or line breaks. Enter at least 3 pairs, with the same number of X and Y values.
Your data stays in your browser — nothing is uploaded.
About 60% of the variation in Y is explained by the linear relationship with X; the other 40% is left unexplained by the line.
Example: X = 1, 2, 3, 4, 5 and Y = 2, 4, 5, 4, 5 — r = 0.7746, R² = 0.60, regression line ŷ = 2.20 + 0.60x.
Behind the numbers
How R² is calculated
First fit the least-squares line ŷ = a + bx through the points, where b is the slope and a is the intercept. Then measure two sums of squares: SS_tot, how far the Y values sit from their own mean, and SS_res, how far the Y values sit from the fitted line. R² is the share of the total variation that the line accounts for.
Worked example: X = 1, 2, 3, 4, 5 and Y = 2, 4, 5, 4, 5. The fitted line is ŷ = 2.20 + 0.60x. The residuals are −0.20, 0.60, 1.00, −0.60 and −0.20, so SS_res = 0.04 + 0.36 + 1.00 + 0.36 + 0.04 = 2.40. The Y values deviate from their mean of 4.00 by −2, 0, 1, 0 and 1, so SS_tot = 6.00. R² = 1 − 2.40 ÷ 6.00 = 0.60, and r = √0.60 = 0.7746.
Worked examples
Example R² values
| X values | Y values | r | R² |
|---|---|---|---|
| 1, 2, 3, 4, 5 | 2, 4, 5, 4, 5 | 0.7746 | 0.60 |
| 1, 2, 3 | 2, 4, 6 | 1.0000 | 1.00 |
| 1, 2, 3, 4 | 1, 3, 2, 4 | 0.8000 | 0.64 |
| 1, 2, 3, 4, 5 | 5, 4, 3, 2, 1 | −1.0000 | 1.00 |
| 10, 20, 30, 40, 50 | 15, 25, 28, 40, 52 | 0.9840 | 0.97 |
Notice the fourth row: a perfect negative line also gives R² = 1.00, because R² measures how closely the points follow a straight line, not whether the line slopes up or down.
Reading R² honestly
R² tells you how much of Y's variation the line explains — not whether X causes Y. A strong R² between ice-cream sales and drownings comes from a shared cause (summer heat), not from one causing the other.
Always plot the data. A curved pattern can give a middling R² even when the relationship is strong, and a single outlier can push R² up or down a lot.
With only 3 points, R² is easy to inflate — three points almost always sit close to some line. Use more points before trusting a high R².
Adding more predictors to a model can only raise R², so a higher R² does not by itself mean a better model. For comparing models with different numbers of predictors, use adjusted R².
Good to know
Your R² questions, answered.
What is the coefficient of determination (R squared)?
R squared (R²) is the share of the variation in Y that a linear relationship with X explains. It runs from 0 to 1: R² = 0.60 means about 60% of the variation in Y is explained by X, and R² = 1.00 means every point falls exactly on the regression line.
How is R squared calculated?
R² = 1 - SS_res / SS_tot, where SS_res is the sum of the squared residuals (how far the points sit from the fitted line) and SS_tot is the total sum of squares (how far the Y values sit from their mean). For a simple linear regression it is also the square of the correlation coefficient, R² = r².
What is a good R squared value?
There is no universal cutoff. In physics or engineering an R² above 0.90 is common, while in social science 0.30 can be meaningful. What matters is the field, the sample size and whether the relationship is really linear. A high R² never proves that X causes Y.
Can R squared be negative?
For a regression fitted by least squares with an intercept, R² is between 0 and 1. It can be negative only for a model forced through the origin or a model that fits worse than the mean of Y. If your data has a constant Y, R² is undefined because there is no variation to explain.