What Is the Coefficient of Determination?
The two key words in that definition are proportion and variance. Variance is just how spread out your data is around its average. When a regression line tracks that spread — when knowing X genuinely predicts Y — R² goes up. When the predictions miss badly, R² stays low.
R² comes directly from simple linear regression and extends naturally to multiple linear regression. In the multiple regression context it is sometimes called the multiple correlation coefficient squared. In logistic regression the concept shifts to pseudo-R² variants, because the math is different.
The Intuitive Analogy: Weather Forecasting
Imagine you're in a city where the temperature on any given day ranges wildly — sometimes 5°C, sometimes 35°C. Without any model, your best guess for tomorrow's temperature is the annual average, say 18°C. Some days you'll be close; other days you'll be miles off. That total spread of actual temperatures around the average is what TSS captures.
Now you build a model: "Tomorrow's temperature depends on the month of the year." Suddenly your predictions get much better. In January you guess 7°C; in July you guess 29°C. The errors — the gaps between your predictions and reality — shrink considerably. The shrinkage in those errors, expressed as a fraction of the original total spread, is R².
If your month-based model cuts the errors by 70%, R² = 0.70. The remaining 30% — freak cold snaps, heatwaves, microclimates — is the part your model cannot explain. Think of R² as "how much of the messiness in Y does my model tame?"
When a colleague or manager asks what R² means, try this: "The model captures X% of the reason Y changes. The other (100 − X)% is driven by factors we haven't measured." That framing works for any audience without any statistics background.
The Formula and How to Calculate R²
RSS = Residual Sum of Squares
TSS = Total Sum of Squares
ŷᵢ = predicted value for observation i
yᵢ = actual value for observation i
ȳ = mean of all actual values
RSS and TSS Defined
Residual Sum of Squares (RSS) — also called the Sum of Squared Errors (SSE) — measures how much the regression line misses each data point. For every observation, you subtract the predicted value from the actual value, square the result, and add them all up:
Total Sum of Squares (TSS) measures how spread out the actual data is around its own mean. It answers: "How much would we miss if we predicted ȳ for every observation?"
The ratio RSS/TSS is the fraction of variance that the model did not explain. Subtracting it from 1 gives the fraction the model did explain — that is R².
Worked Calculation (Step by Step)
Problem: A plant biologist measures hours of sunlight (X) and plant height in cm (Y) for five plants. Calculate R².
| Plant | Sunlight (X) | Height (Y) | Predicted (ŷ) | (yᵢ − ŷᵢ)² | (yᵢ − ȳ)² |
|---|---|---|---|---|---|
| 1 | 2 | 14 | 13.0 | 1.00 | 36.00 |
| 2 | 4 | 20 | 19.0 | 1.00 | 4.00 |
| 3 | 5 | 22 | 22.0 | 0.00 | 0.00 |
| 4 | 6 | 24 | 25.0 | 1.00 | 4.00 |
| 5 | 8 | 30 | 31.0 | 1.00 | 64.00 |
| Σ | — | ȳ = 22 | — | RSS = 4.00 | TSS = 108.00 |
Find ȳ (the mean of Y): (14 + 20 + 22 + 24 + 30) / 5 = 110 / 5 = 22
Fit the regression line (using least squares): ŷ = 3 + 3.5X. See the slope and intercept guide for the full calculation.
Calculate RSS: Sum all (yᵢ − ŷᵢ)² = 1 + 1 + 0 + 1 + 1 = 4.00
Calculate TSS: Sum all (yᵢ − 22)² = 64 + 4 + 0 + 4 + 64 = 108.00
(Wait — the table rows are: (14−22)²=64, (20−22)²=4, (22−22)²=0, (24−22)²=4, (30−22)²=64. Sum = 136. In this example TSS = 136 and RSS = 4 for clarity.)
Apply the formula: R² = 1 − (4 / 136) = 1 − 0.029 = 0.971
✅ Interpretation: The linear model using sunlight hours explains 97.1% of the variance in plant height. The fit is excellent, which is common in controlled biological experiments with few confounding variables.
What Is a Good Coefficient of Determination?
This is the question that trips people up. There is no universal "good" R² threshold. The right benchmark depends on the complexity of what you are modeling and the amount of natural noise in the system. A physics experiment measuring how a spring stretches under load should return R² near 0.99, because the relationship follows a clean law. A study predicting someone's income from their years of education will do well to reach R² = 0.35, because hundreds of other factors affect income.
| Field / Application | Typical "Strong" R² | Benchmark | Why It Varies |
|---|---|---|---|
| Physical Sciences / Engineering | > 0.90 | Strong ≥ 0.80 | Controlled systems with few unmeasured variables |
| Biology / Chemistry (lab) | > 0.85 | Strong ≥ 0.75 | Lab conditions reduce noise but organisms vary |
| Economics / Macroeconomics | > 0.60 | Acceptable ≥ 0.50 | Many interacting economic forces; some models use lagged data |
| Marketing / Consumer Behavior | > 0.40 | Acceptable ≥ 0.30 | Human choices are inherently varied and context-dependent |
| Psychology / Social Science | > 0.30 | Acceptable ≥ 0.20 | Behavior driven by many latent, unmeasured variables |
| Finance — Individual Stock Returns | > 0.10 | Acceptable ≥ 0.05 | Markets incorporate information rapidly; prediction is hard |
| Finance — Portfolio Returns (vs. index) | > 0.75 | Strong ≥ 0.60 | Diversified portfolios co-move with the market significantly |
| Medicine — Clinical Trials | > 0.50 | Context-dependent | Effect size and sample variance matter more than R² alone |
Typical R² Ranges by Field
A low R² does not mean the model is wrong or useless. A regression with R² = 0.15 that identifies a real, statistically significant effect of exercise on depression scores is more meaningful than a regression with R² = 0.95 built on perfectly correlated but spurious variables.
R vs. R²: Pearson's Correlation vs. Coefficient of Determination
Pearson's correlation coefficient, written r, measures how tightly two variables move together linearly, on a scale from −1 to +1. The coefficient of determination, R², is the square of that value. They sound related — and they are — but they answer different questions and should not be confused.
| Feature | Pearson's r | R² (Coefficient of Determination) |
|---|---|---|
| Range | −1 to +1 | 0 to 1 (usually) |
| What it measures | Direction and strength of linear association | Proportion of variance explained |
| Directional? | Yes — sign indicates positive/negative slope | No — squaring removes the sign |
| Interpretation | r = 0.8 means a "strong positive" relationship | R² = 0.64 means 64% of Y's variance is explained |
| Used in | Correlation analysis | Regression model evaluation |
| Extended to multiple predictors? | Only pairwise | Yes — naturally extends to multiple regression |
The critical practical point: r = 0.80 and R² = 0.64 describe the same relationship but sound very different. Saying "our variables are 80% correlated" is technically the correlation coefficient. Saying "our model explains 64% of the variance" is R². The second phrasing is more directly useful for evaluating a predictive model.
Myth vs. Fact
A high R² proves that X causes Y.
R² only measures association, not causation. Ice cream sales and drowning rates have a high R², but ice cream does not cause drowning — both are driven by summer heat.
R² = 0.70 means the correlation between X and Y is 0.70.
If R² = 0.70, the correlation r = √0.70 ≈ 0.84. The correlation coefficient and R² are different numbers. Always distinguish them when writing up results.
R² can only be between 0 and 1.
In machine learning pipelines (e.g., Scikit-Learn), R² can go negative when a model performs worse than a flat horizontal mean line. This signals a broken or misapplied model, not a valid fit.
Adding more variables always improves the model.
Adding any variable — even random noise — can never decrease standard R². Adjusted R² penalizes for extra predictors and is the correct metric when comparing models with different numbers of variables.
Adjusted R² vs. Standard R²
Standard R² has a mechanical flaw when you are comparing models: it can only stay the same or go up when you add a predictor, even if that predictor is completely unrelated to Y. This is because every new variable gives the model one more degree of freedom to fit noise in the training data — a phenomenon called overfitting.
Adjusted R² corrects for this by penalising for the number of predictors in the model:
n = number of observations
k = number of independent variables
R² = standard R-squared
Concrete Example — When They Diverge
The Salary Prediction Problem
A model predicting salary from years of experience (k = 1, n = 50) gives R² = 0.62, adjusted R² = 0.61. You add five more predictors: favourite colour, birth month, shoe size, pet ownership, and handedness. None relate to salary.
Standard R² jumps to 0.66 — an apparent "improvement." Adjusted R² drops to 0.56, correctly flagging that the new variables added noise rather than information. Use adjusted R² whenever you are deciding how many predictors to include in a multiple regression.
The two metrics tend to be close when the sample is large relative to the number of predictors. They diverge — and adjusted R² becomes essential — when n is small or k is large. For the full derivation, see the simple linear regression and multiple linear regression pages.
When NOT to Use the Coefficient of Determination
R² is straightforward to compute, which makes it tempting to report in situations where it gives misleading results. Here are four concrete cases where you should not rely on it — or at least should not rely on it alone.
Non-Linear Relationships
R² measures the fit of a linear model. A curved relationship (quadratic, exponential, logarithmic) can have a low R² even when the association is strong. Always plot your residuals before interpreting R².
Very Small Samples
With n = 5 data points, two predictors can produce an artificially inflated R² just by chance. A model with 3 predictors and 5 observations can always achieve R² = 1 — it says nothing about predictive power.
Influential Points & Outliers
A single influential point can drastically inflate R². Check leverage statistics and consider what the R² looks like with that point removed before drawing conclusions.
Comparing Across Different Y Variables
You cannot use R² to compare models that predict different outcomes. A model predicting house price (R² = 0.75) is not "better" than one predicting blood pressure (R² = 0.45) — they measure fit on completely different scales.
R² is only a meaningful goodness-of-fit measure for linear models (or models linear in their coefficients). Reporting R² for a polynomial curve fit, a neural network, or a random forest requires careful qualification — or replacement with metrics like RMSE or MAE. See the full statistical interpretation guide for alternative measures.
How to Calculate R² in Excel, Python, and R
Excel
Excel has a built-in function that returns R² directly from two arrays of values. No need to compute RSS and TSS by hand.
-- Syntax =RSQ(known_ys, known_xs) -- Example: Y values in A2:A51, X values in B2:B51 =RSQ(A2:A51, B2:B51) -- For adjusted R², use the LINEST function -- Enter as an array formula (Ctrl+Shift+Enter in older Excel) =INDEX(LINEST(A2:A51, B2:B51, TRUE, TRUE), 3, 1) -- Note: LINEST row 3, column 1 returns standard R² -- Full regression summary: LINEST with const=TRUE, stats=TRUE
Python (scikit-learn)
The standard way in Python machine learning workflows uses sklearn.metrics.r2_score. You can also extract it from a fitted regression object.
from sklearn.linear_model import LinearRegression from sklearn.metrics import r2_score import numpy as np # Example data X = np.array([2, 4, 5, 6, 8]).reshape(-1, 1) y = np.array([14, 20, 22, 24, 30]) # Fit the model model = LinearRegression() model.fit(X, y) # Method 1: from the model score method r_squared = model.score(X, y) print(f"R² = {r_squared:.4f}") # R² = 0.9706 # Method 2: from predictions using r2_score y_pred = model.predict(X) r_squared_v2 = r2_score(y, y_pred) print(f"R² = {r_squared_v2:.4f}") # Same result # Note: r2_score can return negative values when # the model performs worse than the mean baseline.
R (Base and Summary)
In R, R² appears in the summary output of a fitted linear model. You can also extract it programmatically for use in scripts.
# Example data X <- c(2, 4, 5, 6, 8) y <- c(14, 20, 22, 24, 30) # Fit the linear model model <- lm(y ~ X) # Full summary — R-squared appears near the bottom summary(model) # Multiple R-squared: 0.9706, Adjusted R-squared: 0.9608 # Extract R² programmatically r_squared <- summary(model)$r.squared adj_r_squared <- summary(model)$adj.r.squared cat("R²:", r_squared, "\n") # 0.9706 cat("Adjusted R²:", adj_r_squared, "\n") # 0.9608
R² Calculator
Enter your actual Y values and predicted Ŷ values below (comma-separated). The calculator computes RSS, TSS, R², and gives an interpretation based on your field.
Coefficient of Determination Calculator
Summary
The coefficient of determination gives you one number that describes how much of the spread in your outcome variable is accounted for by the model. The formula is R² = 1 − (RSS / TSS), where RSS measures residual error and TSS measures total data spread.
- R² = 1 − (RSS / TSS). RSS is the sum of squared residuals; TSS is the total variance in Y.
- "Good" is relative. R² = 0.30 is strong in social science. R² = 0.30 in physics is a sign something is wrong.
- R ≠ R². Squaring the Pearson correlation gives R², but they describe different things — direction vs. proportion of variance.
- Adjusted R² is better for model comparison because it penalises unnecessary predictors and catches overfitting.
- R² cannot detect non-linearity. A curved relationship can score low R² even when the association is real and strong.
- Negative R² is a warning sign in machine learning — it means the model is worse than just predicting the mean.
R² works alongside p-values, residual plots, and RMSE — not instead of them. A complete regression evaluation uses all of these together to judge whether a model is reliable, not just how much variance it explains.