Regression Goodness-of-Fit Model Evaluation 18 min read Updated September 2026
BY: Statistics Fundamentals Team
Reviewed By: Minsa A (Senior Statistics Editor)

Coefficient of Determination (R²): Formula, Interpretation, and Examples

The coefficient of determination, written as R² (R-squared), tells you what fraction of the variation in your outcome variable a regression model explains. It runs from 0 to 1: an R² of 0.0 means the model explains nothing; an R² of 1.0 means it explains everything. Most real models land somewhere between those extremes, and deciding whether that middle number is good or bad depends entirely on your field.

This guide covers the formula, a plain-English interpretation, a worked calculation, benchmark values by industry, the distinction between R and R², adjusted R², when R² misleads you, and exact code for Excel, Python, and R. There is also an interactive calculator at the end.

What You'll Learn
  • ✓ The exact definition and formula: R² = 1 − (RSS / TSS)
  • ✓ A plain-English analogy that makes "proportion of variance" click
  • ✓ A full step-by-step hand calculation with real numbers
  • ✓ Benchmark R² values across physics, social science, finance, and more
  • ✓ Adjusted R² and why it matters when you add predictors
  • ✓ Four situations where you should not trust R²
  • ✓ Code snippets for Excel, Python (sklearn), and R

What Is the Coefficient of Determination?

Definition — Coefficient of Determination
The coefficient of determination (R²) is a goodness-of-fit measure for regression models. It represents the proportion of variance in the dependent variable that the independent variable(s) explain. Values range from 0 to 1, where 1 is a perfect fit and 0 means the model explains nothing beyond the mean.
R² = 1 − (RSS / TSS)

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.

0
No fit — model predicts the mean for every observation
0.50
Half the variance in Y is explained by the model
1.0
Perfect fit — every point sits exactly on the regression line

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?"

💡
Plain-English Translation for Non-Technical Stakeholders

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²

Coefficient of Determination — Core Formula
R² = 1 − (RSS / TSS)
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:

RSS Formula
RSS = Σ (yᵢ − ŷᵢ)²

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?"

TSS Formula
TSS = Σ (yᵢ − ȳ)²

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)

Worked Example — Hand Calculation

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ᵢ − ȳ)²
121413.01.0036.00
242019.01.004.00
352222.00.000.00
462425.01.004.00
583031.01.0064.00
Σ—ȳ = 22—RSS = 4.00TSS = 108.00
1

Find ȳ (the mean of Y): (14 + 20 + 22 + 24 + 30) / 5 = 110 / 5 = 22

2

Fit the regression line (using least squares): ŷ = 3 + 3.5X. See the slope and intercept guide for the full calculation.

3

Calculate RSS: Sum all (yᵢ − ŷᵢ)² = 1 + 1 + 0 + 1 + 1 = 4.00

4

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.)

5

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.

Formula source: Montgomery, D.C., Peck, E.A., & Vining, G.G. (2012). Introduction to Linear Regression Analysis (5th ed.). Wiley. Chapter 2.4.

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

Physics / Engineering
0.90+
Biology (lab)
0.80+
Economics
0.60
Marketing
0.40
Psychology
0.30
Stock Returns
0.10
⚠️
The "R² Must Be High" Fallacy

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 +10 to 1 (usually)
What it measuresDirection and strength of linear associationProportion of variance explained
Directional?Yes — sign indicates positive/negative slopeNo — squaring removes the sign
Interpretationr = 0.8 means a "strong positive" relationshipR² = 0.64 means 64% of Y's variance is explained
Used inCorrelation analysisRegression model evaluation
Extended to multiple predictors?Only pairwiseYes — 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

❌ Myth

A high R² proves that X causes Y.

✅ Fact

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.

❌ Myth

R² = 0.70 means the correlation between X and Y is 0.70.

✅ Fact

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.

❌ Myth

R² can only be between 0 and 1.

✅ Fact

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.

❌ Myth

Adding more variables always improves the model.

✅ Fact

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:

Adjusted R² Formula
R²adj = 1 − [(1 − R²) × (n − 1) / (n − k − 1)]
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 Invalid for Non-Linear Regression

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.

Excel — RSQ Function
-- 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.

Python — scikit-learn
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.

R — lm() and summary()
# 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.

⚡ Key Takeaways
  • 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.