R squared (R², also called the coefficient of determination) measures how well a regression line fits a dataset — the share of the variance in the outcome variable that the model accounts for. An R² of 0.73 means the model explains 73% of the variation in the response; the other 27% comes from factors the model does not capture or from plain randomness. R² ranges from 0 (the model explains nothing) to 1 (it explains everything), and it comes with a close cousin, adjusted R², that corrects for how many predictors went into the model. This guide works through both, with the arithmetic shown at every step.
Key takeaways
| Point | Details |
|---|---|
| R² measures how well a model fits | It is the share of the variance in y accounted for by the regression line, on a 0-to-1 scale — 0 means no fit, 1 means a perfect fit. |
| R² equals r² in simple regression | With exactly one predictor, R² is the square of the Pearson correlation coefficient r, which is where the name comes from. |
| Adding predictors can only raise R² | Least-squares fitting can never make R² fall when you add a variable, even a meaningless one — that mechanical inflation is why adjusted R² exists. |
| Adjusted R² penalizes extra predictors | It divides by residual degrees of freedom instead of total degrees of freedom, so it can fall — or even go negative — when a predictor adds nothing. |
| Neither statistic proves a good model | A high R² does not rule out overfitting, a wrong functional form, or a relationship with no causal meaning; check residual plots and out-of-sample performance too. |
Quick Checklist: Is Your R-Squared Telling You What You Think?
Before you report an R² value or compare two models on it, run through these checks. Most R²-related mistakes come from skipping one of them.
Quick checklist: reading an R-squared value correctly
- Compare against your field, not a universal cutoff A 0.95 can be mediocre in engineering and excellent in social science — there is no fixed "good" threshold.
- Count the predictors before comparing models If two models have different numbers of predictors, compare adjusted R², not raw R².
- Look at the residual plot, not just the number A high R² with a patterned residual plot usually means the wrong functional form, not a good fit.
- Check performance on new data A high R² on the data used to fit the model says nothing about predictions on a held-out sample.
- Confirm it is simple regression before using r² The identity R² = r² only holds with exactly one predictor; it does not apply once you add a second.
Think of these as a five-second audit, not a full diagnostic — they catch the mistakes covered in detail later in this guide.
What Does R-Squared Measure?
R² quantifies how much of the total variation in a dependent variable y is explained by a regression model, compared with a baseline that just predicts the sample mean ȳ for every observation. That comparison is built from three sums of squares.
The total sum of squares (SST) is the spread of the data around the mean-only baseline:
SST = Σ(yᵢ − ȳ)²
The fitted model produces a predicted value ŷᵢ for each observation. The regression sum of squares (SSR) is the part of that spread the model actually explains:
SSR = Σ(ŷᵢ − ȳ)²
The residual sum of squares (SSE) is what is left over — the scatter of the actual values around the fitted line:
SSE = Σ(yᵢ − ŷᵢ)²
| Quantity | Formula | What it measures |
|---|---|---|
| SST (total) | Σ(yᵢ − ȳ)² | Total variation in y around its mean |
| SSR (regression) | Σ(ŷᵢ − ȳ)² | Variation the model explains |
| SSE (residual) | Σ(yᵢ − ŷᵢ)² | Variation left unexplained |
These three satisfy the identity SST = SSR + SSE, and R² is simply the explained share of the total. R’s documentation for summary.lm states this same identity in its own notation, R² = 1 − ΣRᵢ²/Σ(yᵢ − ȳ)², where Rᵢ is the residual for observation i — the same quantity as SSE and SST here, just written with sums instead of names:
R² = SSR / SST = 1 − (SSE / SST)
An R² of 0.73 means the model explains 73% of the total variance in y; the remaining 27% is residual variation the predictor (or predictors) do not capture.
A quick sanity check worth doing on any dataset before trusting the number: SST, SSR, and SSE should always satisfy SST = SSR + SSE exactly (within rounding). If they don’t, the fitted values or the mean were computed incorrectly somewhere upstream — check that before reporting R² at all.
What Is the R-Squared Formula?
For simple linear regression — one predictor, fitted by the method the NIST/SEMATECH e-Handbook’s linear least squares page describes — R² has a direct link to the Pearson correlation coefficient r between x and y:
R² = r²
That identity is literally where the name “R-squared” comes from: in the one-predictor case, it is the squared Pearson correlation. OpenStax’s Introductory Statistics 2e calls r² exactly that — “the coefficient of determination” — when it introduces the regression equation. Squaring r removes its sign, so R² is always non-negative regardless of whether the relationship runs positive or negative. The correlation coefficient guide covers how r itself is computed and interpreted.
For multiple regression, with more than one predictor, that shortcut no longer applies — compute R² directly from the sums of squares instead:
R² = 1 − (SSE / SST)
This general form works for any number of predictors, while R² = r² is only valid with exactly one. For more than one predictor, R² is still interpreted the same way — the share of variance explained — even though it no longer reduces to a single correlation you can square by hand.
How Do You Interpret an R-Squared Value?
There is no universal “good” R² — the right benchmark depends on the field and what you are trying to predict.
| Field | What to expect | Why |
|---|---|---|
| Physical sciences & engineering | Usually much higher | Physical laws govern the relationship, leaving little unexplained noise. |
| Social sciences & economics | Usually moderate | Human behavior carries far more unmeasured variation. |
| Finance (stock-return models) | Often quite low | Returns are dominated by unpredictable noise; even a small, statistically significant R² can still be economically useful. |
Three traps come up repeatedly once you move past the headline number:
Adding predictors inflates R² mechanically. Least-squares regression can only keep R² the same or raise it when you add a predictor, even pure noise, because the optimizer gains one more free parameter to reduce SSE. That mechanical inflation is exactly why adjusted R² (below) exists.
A high R² does not guarantee a well-fitting model. The NIST/SEMATECH e-Handbook’s guidance on model validation is direct about this: “a high R² value does not guarantee that the model fits the data well,” and quoting R² alone — without graphical residual analysis — is one of the most common and most overlooked shortcuts in model validation. A model can also show R² near 1 on the data used to fit it and still perform poorly on a held-out sample, a classic sign of overfitting. Always check the residual plot and performance on new or cross-validated data before trusting the fit.
A high R² is not evidence of causation. It tells you the model’s predicted values track the observed ones closely; it says nothing about whether the predictor causes the outcome. See correlation vs causation for the full argument, and what is correlation for how association differs from a causal claim.
Restricting the range of x can shrink R² even when the underlying relationship is strong. If you fit a regression only on a narrow slice of x values — say, students who all scored within a few points of each other on an entry exam — the predictor has less room to explain variation in y, and R² drops even though the true relationship between the full ranges of x and y may be just as tight. This is the same range-restriction effect that weakens a correlation coefficient, since R² = r² in the one-predictor case.
A Worked Example: Computing R-Squared by Hand
Data: x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 6. These are the linear regression calculator’s defaults, so you can check every number below against the tool.
Step 1 — compute the means.
x̄ = (1 + 2 + 3 + 4 + 5) / 5 = 3
ȳ = (2 + 4 + 5 + 4 + 6) / 5 = 4.2
Step 2 — fit the least-squares line. The slope and intercept come from the same cross-products used for the correlation coefficient. Work across each point:
| xᵢ | yᵢ | xᵢ − x̄ | yᵢ − ȳ | (xᵢ − x̄)(yᵢ − ȳ) | (xᵢ − x̄)² |
|---|---|---|---|---|---|
| 1 | 2 | −2 | −2.2 | 4.4 | 4 |
| 2 | 4 | −1 | −0.2 | 0.2 | 1 |
| 3 | 5 | 0 | 0.8 | 0 | 0 |
| 4 | 4 | 1 | −0.2 | −0.2 | 1 |
| 5 | 6 | 2 | 1.8 | 3.6 | 4 |
| Sum | 8.0 | 10 |
Σ(xᵢ − x̄)(yᵢ − ȳ) = 8.0
Σ(xᵢ − x̄)² = 10.0
b₁ = 8.0 / 10.0 = 0.8
b₀ = ȳ − b₁ · x̄ = 4.2 − 0.8 × 3 = 1.8
Fitted line: ŷ = 1.8 + 0.8x
Step 3 — compute predicted values, SSE, and SST.
| xᵢ | yᵢ | ŷᵢ | (yᵢ − ŷᵢ)² | (yᵢ − ȳ)² |
|---|---|---|---|---|
| 1 | 2 | 2.6 | 0.36 | 4.84 |
| 2 | 4 | 3.4 | 0.36 | 0.04 |
| 3 | 5 | 4.2 | 0.64 | 0.64 |
| 4 | 4 | 5.0 | 1.00 | 0.04 |
| 5 | 6 | 5.8 | 0.04 | 3.24 |
| Sum | 2.40 (SSE) | 8.80 (SST) |
Step 4 — compute R². Two equivalent routes, both using the SSE and SST from Step 3:
SSR = SST − SSE = 8.80 − 2.40 = 6.40
R² = SSR / SST = 6.40 / 8.80 ≈ 0.727
R² = 1 − (SSE / SST) = 1 − (2.40 / 8.80) ≈ 0.727
Interpretation: the regression line explains about 72.7% of the variance in y; the remaining 27.3% is residual scatter the line does not capture. You can confirm this through the correlation route too: r = 8.0 / √(10.0 × 8.80) ≈ 0.8528, and r² ≈ 0.7273 — the same result, as the formula in the previous section predicts.
Try the Calculator
Enter x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 6 below to reproduce R² ≈ 0.727. The tool also reports the slope, intercept, and correlation coefficient r.
For the full standalone tool, open the linear regression calculator; for the correlation step on its own, use the correlation coefficient calculator.
What Is Adjusted R-Squared?
Adjusted R² corrects the ordinary coefficient of determination for the number of predictors in the model. Because adding any predictor — even a meaningless one — can only hold R² steady or push it up, raw R² inflates as a model grows. Adjusted R² penalizes that inflation by dividing by residual degrees of freedom instead of total degrees of freedom, a correction documented alongside the ordinary coefficient in OpenIntro’s Introduction to Modern Statistics, multiple-regression chapter:
Adjusted R² = 1 − (1 − R²) × (n − 1) / (n − k − 1)
where n is the number of observations and k is the number of predictors (not counting the intercept). The multiplier (n − 1) / (n − k − 1) is always ≥ 1, so adjusted R² is always ≤ R². Adjusted R² rises when a new predictor genuinely helps and falls when a predictor contributes less than chance would predict.
Continuing the worked example with n = 5, k = 1, R² ≈ 0.7273:
Adjusted R² = 1 − (1 − 0.7273) × (5 − 1) / (5 − 1 − 1)
= 1 − 0.2727 × (4 / 3)
= 1 − 0.3636
= 0.6364
The gap between R² (0.727) and adjusted R² (0.636) is large here mainly because n = 5 is tiny; with n = 100 and the same R² and k, adjusted R² works out to about 0.7245 — nearly identical to R².
What happens if you add a near-useless second predictor to this same dataset? Suppose it nudges R² up only slightly, to 0.735, with n still 5 but k now 2:
Adjusted R² = 1 − (1 − 0.735) × (5 − 1) / (5 − 2 − 1)
= 1 − 0.265 × (4 / 2)
= 1 − 0.53
= 0.47
R² rose from 0.727 to 0.735, but adjusted R² fell from 0.636 to 0.47 — the predictor cost more in lost degrees of freedom than it added in explained variance. That divergence is the entire point of the statistic.
When Should You Use Adjusted R-Squared Instead of R-Squared?
| Situation | Use |
|---|---|
| Simple regression (one predictor), n reasonably large | Either — they differ only slightly |
| Comparing models with the same number of predictors | Either |
| Comparing models with different numbers of predictors | Adjusted R² |
| Reporting overall fit in a write-up | Report both |
| Stepwise or forward-selection model building | Adjusted R² (or AIC/BIC alongside it) |
In simple regression with a reasonably large sample, R² and adjusted R² sit close together because there is only one predictor to penalize and the (n − 1)/(n − k − 1) multiplier is close to 1. With a small sample, that gap can still be large — the worked example above has only n = 5, which is exactly why its R² (0.727) and adjusted R² (0.636) are noticeably different despite having just one predictor. The gap widens further as you add predictors in multiple regression, which is exactly when the correction starts to matter for deciding whether a variable earns its place in the model.
Adjusted R² is a good first check for model selection, but it is not the only one. Many analysts also look at the Akaike Information Criterion (AIC) and the Bayesian Information Criterion (BIC), which apply different complexity penalties and can behave differently when a model is badly misspecified. Treat adjusted R² as a quick, intuitive screen and confirm a close call with one of those criteria before finalizing a model.
What Are Real-World Applications of R-Squared?
R² shows up anywhere a model needs to be judged against raw data, not just in textbook regression exercises:
- Finance. CAPM and factor-model regressions report R² to show how much of a stock’s or portfolio’s return variation is explained by market movements or named risk factors, with the unexplained share attributed to idiosyncratic risk.
- Economics. Macroeconomic models that regress consumption, GDP growth, or inflation on a handful of predictors use R² as a first-pass check of explanatory power before moving to more detailed diagnostics.
- Calibration curves. Laboratory instruments are calibrated by regressing a known concentration or quantity against an instrument reading; a near-1 R² on that calibration line is often required before the instrument is trusted for unknown samples.
- Machine learning baselines. Before adopting a complex model, practitioners often fit a simple linear regression and report its R² as a baseline that the complex model needs to beat by a meaningful margin, not just a fractional amount.
- Growth and dose-response curves. Biology and agriculture use R² to judge how well a fitted growth curve or dose-response model tracks observed measurements across experimental conditions.
Across all of these, R² answers the same narrow question — how much of the observed variation does this specific model explain — and none of them treat it as proof that the model is correctly specified or causal.
How Do You Calculate R-Squared in Excel, Python, and R?
Excel: =RSQ(known_y's, known_x's) simple-regression R² directly
LINEST() with stats=TRUE full regression output incl. R²
Python: from sklearn.metrics import r2_score
r2_score(y_true, y_pred) R² from actual vs. predicted values
import statsmodels.api as sm
model = sm.OLS(y, sm.add_constant(x)).fit()
model.rsquared R²
model.rsquared_adj adjusted R², computed directly
R: model <- lm(y ~ x)
summary(model)$r.squared R²
summary(model)$adj.r.squared adjusted R²
Microsoft’s documentation for the RSQ function confirms it returns the square of the Pearson correlation coefficient for paired x and y ranges — the same R² = r² identity covered above. scikit-learn’s r2_score reference computes R² from any set of true and predicted values, which also makes it usable for models beyond simple linear regression, though it has no built-in adjusted-R² option. statsmodels’ RegressionResults reference documents the rsquared and rsquared_adj attributes that an OLS fit returns directly. R’s documentation for summary.lm shows that fitting a model with lm() and calling summary() on it reports both the “Multiple R-squared” and the “Adjusted R-squared” in the same output.
Common Mistakes With R-Squared
- Treating R² alone as proof of a good model. A high R² means the model fits the training data closely; it says nothing about whether the model is correctly specified, practically meaningful, or accurate on data it hasn’t seen. Always check residual plots alongside the number, not instead of it.
- Comparing R² across models with different numbers of predictors. Raw R² only ever rises as you add variables, including ones that are pure noise, so a “better” R² on a larger model can be meaningless. Switch to adjusted R² — or AIC/BIC — for that comparison.
- Trusting R² from a very small sample. With n = 5, as in the worked example, R² is highly sensitive to individual points — remove or change one observation and the value can shift sharply. Treat small-sample R² as a rough estimate, not a precise measurement, and corroborate it with a larger sample before relying on it.
- Confusing R² with prediction error. R² is a relative measure of fit, not an absolute one. Two models with the same R² can have very different errors in the original units if their outcome variables are on different scales; compare root-mean-square error (RMSE) or mean absolute error when the original units matter.
- Assuming linearity. R² is built from a linear decomposition of variance. Fitting a straight line to a curved relationship understates how predictable the outcome actually is — inspect a scatter plot before trusting a linear R², and consider a polynomial or transformed predictor if the pattern curves.
- Reading R² as causation. An R² of 0.85 means the linear model explains 85% of the variance in this particular sample, nothing more. Causation needs a controlled experiment or careful adjustment for confounders, not a high R² on observational data.
Statohub’s Take on R-Squared
Statohub’s position is that R² is a useful, honest summary of fit as long as you treat it as relative, not absolute. The single habit worth building is checking whether you are comparing models with the same number of predictors before trusting raw R² at all — if you aren’t, adjusted R² is the number that actually answers the question you’re asking.
Put R-Squared to Work With Statohub’s Tools
The calculator above computes R² directly from paired x and y values — enter your own data to check the slope, intercept, correlation coefficient, and R-squared together. The full linear regression calculator offers the same output as a standalone page, and the correlation coefficient calculator isolates just the r step behind R² = r². The Regression & Correlation hub rounds out the neighboring topics, including how the linear regression line itself is fit and how regression to the mean differs from a regression model’s fit statistic despite the shared name. Statohub’s full calculators hub covers every other statistics tool on the site.
Sources
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods — 4.4.4. How can I tell if a model fits my data? NIST
- NIST/SEMATECH e-Handbook of Statistical Methods — 4.1.4.1. Linear Least Squares Regression NIST
- OpenStax — 12.3 The Regression Equation, Introductory Statistics 2e OpenStax
- OpenIntro — Introduction to Modern Statistics (2e), Chapter 8: Linear regression with multiple predictors OpenIntro
- scikit-learn — sklearn.metrics.r2_score reference scikit-learn
- statsmodels — RegressionResults reference (rsquared and rsquared_adj) statsmodels
- The R Project — stats::summary.lm documentation (Multiple and Adjusted R-squared) The R Project
- Microsoft Support — RSQ function Microsoft
FAQ
Frequently asked questions
- What does R squared measure?
- R squared (R²) measures the proportion of variance in the dependent variable that a regression model explains. An R² of 0.65 means the model accounts for 65% of the variability in the outcome, and the remaining 35% is unexplained by the predictors included.
- What is the difference between r and R-squared?
- Lowercase r, the Pearson correlation coefficient, measures the strength and direction of a linear relationship and ranges from −1 to +1. Uppercase R² is r squared: it measures the proportion of variance explained and ranges from 0 to 1, losing the sign in the process. See the correlation coefficient guide for how r itself is calculated.
- Can R-squared be negative?
- Ordinary R² from a standard least-squares fit is always between 0 and 1, because the fitted line can only perform as well as or better than the mean-only baseline. Adjusted R², however, can be negative when the number of predictors is large relative to the sample size — a clear warning sign of overfitting.
- What does an R-squared of zero mean?
- An R² of zero means the regression model explains none of the variance in y — the fitted line performs no better than simply predicting the sample mean ȳ for every observation. That usually points to either a genuinely weak or nonexistent linear relationship between x and y, or a misspecified model, such as fitting a straight line to a clearly curved pattern.
- What does an R-squared of 1 mean?
- An R² of 1 means the model explains 100% of the variance in y — every predicted value ŷᵢ matches the observed value yᵢ exactly, with no residuals left over. Real data almost never produces R² = 1; when it does happen, it usually signals a data-entry error, perfectly collinear predictors, or a model that has memorized the training set rather than captured a genuine relationship.
- What is a good R-squared value?
- There is no universal threshold. Physical sciences and engineering, where physical laws dominate, typically produce much higher R² values than the social sciences, where human behavior carries far more unmeasured variation; financial return models often report quite low R² that can still be practically useful. Compare your R² to what is typical in your specific field rather than to a fixed number.
- Why does R-squared always increase when you add predictors?
- Adding any predictor gives least-squares regression one more degree of freedom to reduce the residual sum of squares. Since R² = 1 − SSE/SST and SST does not change, R² can only stay the same or rise, even if the new predictor is pure noise. Adjusted R² corrects for this by dividing by residual degrees of freedom instead of total degrees of freedom.
- When should I use adjusted R-squared instead of R-squared?
- Use adjusted R² whenever you are comparing models with a different number of predictors, since raw R² mechanically favors the larger model. For a single, fixed model, or for comparing models with the same number of predictors, ordinary R² is simpler and tells the same story.