R-Squared Calculator
Calculate R² (coefficient of determination) for linear regression. Measures how much variance in Y is explained by X. Includes adjusted R², RMSE, and F-statistic.
R² (Coefficient of Determination)
—
Correlation Coefficient r —
Interpretation —
Extended More scenarios, charts & detailed breakdown ▾
R²
—
Slope (b) —
Intercept (a) —
Sum of Squared Errors (SSE) —
Professional Full parameters & maximum detail ▾
Model Fit
R² —
RMSE (Root Mean Squared Error) —
F-statistic —
Interpretation
Interpretation —
How to Use This Calculator
- Enter X values and Y values as comma-separated lists (must have equal count).
- Read R², the correlation coefficient r, and interpretation instantly.
- Use Simple Linear R² tab for regression line (slope, intercept) and SSE alongside R².
- Use Adjusted R² tab: enter R², n, and k to penalize for extra predictors.
- Use From Correlation r tab to convert a known r value to R².
- Professional tab adds RMSE and F-statistic for full regression output.
Formula
R² = 1 − SSE/SST = r² (for simple linear regression)
Adjusted R² = 1 − (1 − R²) × (n−1)/(n−k−1)
Example
X = [1,2,3,4,5], Y = [2.1,3.9,6.0,8.2,10.1]. R ≈ 0.9996, R² ≈ 0.9992 — the linear model explains 99.9% of variance in Y.
Frequently Asked Questions
- R², the coefficient of determination, measures the proportion of variance in the dependent variable (Y) that is explained by the independent variable(s) (X) in a regression model. An R² of 0.85 means the model explains 85% of the total variation in Y — the remaining 15% is unexplained, attributed to other factors or random noise. Formally, R² = 1 − (SSE / SST), where SSE is the sum of squared errors (residuals from the regression line) and SST is the total sum of squares (variance around the mean of Y). When SSE = 0, the model fits perfectly (R² = 1). When SSE = SST, the model is no better than simply predicting the mean (R² = 0). For simple linear regression, R² equals the square of the Pearson correlation coefficient: R² = r². An R² of 0.85 means r = ±0.92, indicating a strong linear relationship. Importantly, R² measures goodness of fit to the training data — it does not directly measure prediction accuracy on new data, does not imply causation, and can be artificially inflated by adding irrelevant predictors in multiple regression.
- R² has a fundamental flaw in multiple regression: it always increases when you add a new predictor, even if that predictor has no meaningful relationship with Y. An irrelevant random predictor will still add a tiny bit of explained variance just by chance, pushing R² up. This means that comparing R² across models with different numbers of predictors is misleading — the model with more predictors will almost always appear better. Adjusted R² corrects for this by applying a penalty for each additional predictor: Adjusted R² = 1 − (1 − R²) × (n − 1) / (n − k − 1), where n is the number of observations and k is the number of predictors. When a new predictor improves the model more than expected by chance, adjusted R² increases. When a predictor is irrelevant, adjusted R² decreases even though R² would still increase. Adjusted R² can be negative if the model is very poor. For simple linear regression with one predictor, R² and adjusted R² are equal. Always use adjusted R² when comparing models with different numbers of predictors, or when deciding whether to include additional variables in a regression model.
- No — high R² is not sufficient evidence of a good model and can be misleading in several ways. First, high R² does not imply causation. A regression of ice cream sales on shark attacks might show R² = 0.95 because both are driven by summer heat, but neither causes the other. Second, high R² on training data may reflect overfitting — memorizing noise in the data rather than learning true patterns. A polynomial fit of degree n-1 through n points achieves R² = 1.0 but predicts new data poorly. Always evaluate out-of-sample performance (cross-validation, test set). Third, Anscombe's Quartet is the canonical example: four datasets with wildly different patterns (linear, nonlinear, outlier-driven, constant X with one outlier) can all have nearly identical R² values (around 0.67). This proves R² does not capture whether the linear model is even the right functional form. Fourth, in some fields a high R² is inherent — time series with strong trends often show R² > 0.9 for trivial reasons. The model diagnostic suite should include residual plots, Q-Q plots, influential point detection, and out-of-sample validation alongside R².
- Yes, R² can be negative, and this is a meaningful outcome that indicates the model performs worse than simply predicting the mean of Y for every observation. The R² formula is 1 − SSE/SST. SSE is always non-negative (sum of squared differences). SST is the total variance. For ordinary least squares (OLS) regression — where the model is fit by minimizing SSE — SSE ≤ SST always, so R² ≥ 0. However, in these situations R² can go negative: (1) When the model is computed on training data but evaluated on a test set — the fitted coefficients may not minimize SSE on new data, so SSE can exceed SST. (2) When the model is constrained (e.g., forced through the origin without an intercept) — the least-squares criterion without intercept can give a worse fit than the mean. (3) Adjusted R² can be negative by design when the model fit is very poor relative to the number of predictors. (4) Some non-linear models evaluated using the R² formula (which was designed for linear regression) can give negative values. A negative R² is a clear signal that the model is inappropriate — you should reconsider the functional form, predictors, or whether a regression model is suitable at all.
- The correlation coefficient r and R² are closely related but measure different things. For simple linear regression (one predictor), R² = r². So r = 0.9 gives R² = 0.81. But r measures the strength and direction of linear association between two variables (ranging from −1 to +1), while R² measures the proportion of variance in Y explained by the model (ranging from 0 to 1, with no sign). Knowing r = −0.9 tells you the relationship is strong and negative (as X increases, Y decreases), while R² = 0.81 tells you 81% of Y's variance is explained — the sign is lost. For multiple regression with k predictors, R² is no longer the square of a single correlation — it relates to the multiple correlation R (the correlation between Y and the fitted values), so R² = R². A key conceptual difference: r is a symmetric bivariate statistic (the correlation between X and Y equals the correlation between Y and X), while R² from regression is asymmetric — Y is the outcome being explained, X is the predictor. The regression R² answers 'how well does X predict Y?' while r answers 'how linearly associated are X and Y?'
Related Calculators
Sources & References (5) ▾
- Galton F — Regression Towards Mediocrity in Hereditary Stature (1886) — Journal of the Anthropological Institute
- Pearson K — On the Criterion for a Given System of Deviations (1896) — The London, Edinburgh, and Dublin Philosophical Magazine
- OpenStax Statistics — Chapter 12: Linear Regression and Correlation — OpenStax
- NIST/SEMATECH e-Handbook — Regression Analysis — NIST
- Hastie T, Tibshirani R, Friedman J — The Elements of Statistical Learning, 2nd Edition — Springer