R-Squared Calculator Formula
Understand the math behind the r-squared calculator. Each variable explained with a worked example.
Formulas Used
R² (Coefficient of Determination)
r_squared = ss_reg / ss_totalR (Correlation Coefficient)
r_value = sqrt(ss_reg / ss_total)Residual Sum of Squares (SSE)
ss_resid = ss_total - ss_regVariables
| Variable | Description | Default |
|---|---|---|
ss_reg | Regression Sum of Squares (SSR) | 800 |
ss_total | Total Sum of Squares (SST) | 1000 |
How It Works
R-Squared (Coefficient of Determination)
R² measures the proportion of variance in the dependent variable that is explained by the regression model.
Formula
R² = SSR / SST = 1 - SSE / SST
where SSR is the regression sum of squares, SST is the total sum of squares, and SSE is the residual sum of squares. R² ranges from 0 (model explains nothing) to 1 (perfect fit).
Worked Example
A regression with SSR = 800 and SST = 1000.
- 01R² = 800 / 1000 = 0.80
- 02The model explains 80% of the variance in y.
- 03SSE = 1000 - 800 = 200
- 04R = sqrt(0.80) = 0.8944
Frequently Asked Questions
What is a good R² value?
It depends on the field. In physics, R² > 0.99 is expected. In social sciences, R² > 0.3 may be meaningful. In finance, R² > 0.5 is often good. Context and theory matter more than arbitrary thresholds.
Can R² decrease when adding predictors?
No. R² can only increase (or stay the same) with more predictors. This is why adjusted R² was invented, which penalizes for extra parameters and can decrease if a predictor does not improve the model enough.
Does high R² mean the model is correct?
No. R² only measures linear fit, not whether the model is appropriate. A polynomial may give higher R² but overfit the data. Always check residual plots for patterns indicating model misspecification.
Learn More
Guide
Regression Analysis Guide
Comprehensive guide to regression analysis. Learn how linear regression works, how to interpret slope and intercept, R-squared, residuals, and when to use regression.
Ready to run the numbers?
Open R-Squared Calculator