R-Squared Calculator
Calculate the coefficient of determination (R²), adjusted R², and sum of squares components from observed and predicted values. Evaluate how well your model fits the data. See also our Linear Regression Calculator, Correlation Calculator, and Standard Error Calculator.
How to Use the R-Squared Calculator
R-squared (R²) is the coefficient of determination, measuring the proportion of variance in the dependent variable that is predictable from the independent variable(s). It tells you how well your model's predictions match the actual observed values. An R² of 1.0 means perfect prediction; an R² of 0 means the model is no better than simply predicting the mean.
Enter your observed (actual) values and predicted (model) values as comma-separated numbers. Both lists must have the same number of values. Optionally specify the number of predictors to calculate adjusted R², which penalizes for model complexity. Click Calculate to see R², adjusted R², and the decomposition of variance into regression and error components.
The total sum of squares (SST) measures total variability in the data. It decomposes into SSR (variance explained by the model) and SSE (unexplained variance or error). R² = SSR/SST = 1 - SSE/SST. Adjusted R² accounts for the number of predictors, preventing artificial inflation of R² when adding irrelevant variables to a model.
When evaluating model quality, always consider R² in context. In physical sciences, R² above 0.95 is typical. In social sciences, R² of 0.3-0.5 may represent a good model because human behavior is inherently variable. Compare R² across competing models to determine which explains more variance, but also check that residuals are randomly distributed and the model assumptions are met.
Formula
R-Squared:
R² = 1 - SSE/SST = SSR/SST
Sum of Squares Components:
SST = Σ(yᵢ - ȳ)² (Total)
SSE = Σ(yᵢ - ŷᵢ)² (Error/Residual)
SSR = SST - SSE (Regression)
Adjusted R²:
R²_adj = 1 - [(1-R²)(n-1)] / (n-k-1)
where k = number of predictors, n = sample size
F-statistic (overall significance):
F = (SSR/k) / (SSE/(n-k-1)) = (R²/k) / ((1-R²)/(n-k-1))
Root Mean Square Error:
RMSE = √(SSE/n)
Example Calculation
Observed: 3, 5, 7, 9, 11
Predicted: 3.2, 4.8, 7.1, 8.9, 11.0
Mean of observed: ȳ = 7.0
SST = (3-7)² + (5-7)² + (7-7)² + (9-7)² + (11-7)² = 16+4+0+4+16 = 40
SSE = (3-3.2)² + (5-4.8)² + (7-7.1)² + (9-8.9)² + (11-11)² = 0.04+0.04+0.01+0.01+0 = 0.10
R² = 1 - 0.10/40 = 1 - 0.0025 = 0.9975
Adjusted R² (k=1): 1 - [(1-0.9975)(4)] / (3) = 1 - 0.0033 = 0.9967
Interpretation: Excellent fit (99.75% of variance explained)
Reference Table
| R² Range | Quality | Typical Field | Note |
|---|---|---|---|
| 0.95 - 1.00 | Excellent | Physics, engineering | Near-perfect prediction |
| 0.80 - 0.95 | Very Good | Chemistry, biology | Strong predictive power |
| 0.60 - 0.80 | Good | Economics, medicine | Useful for prediction |
| 0.40 - 0.60 | Moderate | Social sciences | Some predictive value |
| 0.20 - 0.40 | Weak | Psychology, education | Limited prediction |
| 0.00 - 0.20 | Very Weak | Any (poor model) | Model needs improvement |
| < 0 | Worse than mean | Any (bad model) | Model is counterproductive |
Frequently Asked Questions
What is R-squared?
R-squared (R²) is the coefficient of determination, representing the proportion of variance in the dependent variable that is explained by the model. It ranges from 0 to 1 for well-specified models (though it can be negative for poorly fitting models). An R² of 0.75 means 75% of the variability in the outcome is accounted for by the predictors. It is the most common measure of model fit in regression analysis.
What is the difference between R² and adjusted R²?
R² always increases (or stays the same) when you add more predictors, even if they are irrelevant. Adjusted R² penalizes for model complexity by accounting for the number of predictors relative to sample size. It can decrease when adding unhelpful variables, making it better for comparing models with different numbers of predictors. Use adjusted R² when evaluating multiple regression models or deciding whether to include additional variables.
Can R² be negative?
Yes. R² can be negative when the model fits worse than a horizontal line at the mean (i.e., the model's predictions are worse than simply predicting the average for every observation). This happens with poorly specified models, incorrect functional forms, or when applying a model to data very different from the training data. A negative R² is a strong signal that the model is inappropriate.
What is a good R² value?
It depends on the field. In physics and engineering, R² > 0.95 is expected. In social sciences, R² of 0.3-0.5 may be considered good because human behavior is inherently variable. In finance, even R² of 0.1 can be valuable for trading strategies. Never judge R² in isolation — consider the context, sample size, number of predictors, and whether the goal is explanation or prediction.
Does high R² mean the model is correct?
No. A high R² does not guarantee the model is correctly specified. You can get high R² with: (1) overfitting (too many predictors relative to observations), (2) spurious correlations, (3) wrong functional form that happens to fit the data range, or (4) omitted variable bias. Always check residual plots, use cross-validation, and consider theoretical justification alongside R². A model can have high R² and still be misleading.
How do SST, SSR, and SSE relate?
SST (Total Sum of Squares) = SSR (Regression Sum of Squares) + SSE (Error Sum of Squares). SST measures total variability in the data around the mean. SSR measures variability explained by the model. SSE measures unexplained variability (residuals). R² = SSR/SST = 1 - SSE/SST. A good model has large SSR relative to SSE, meaning most variability is explained rather than left as error.