R Squared Calculator
Get R squared from residual and total sums of squares.
What it does
R squared reports how much variance a model explains. Total variance splits into explained plus residual. Dividing residual by total gives the leftover share, and one minus that leftover is R squared.
The tool above takes SSres and SStot and returns R2, explained percent, and unexplained share. The defaults 20 and 100 match the worked example, so the page opens showing 0.8.
A value of 0.8 means 80 percent of variance is captured and 0.2 remains. A value of 0 means the model does no better than the mean. A value of 1 means points sit exactly on the fit. Context decides what counts as good: physics often demands 0.99, social data may prize 0.3.
This simple form suits ordinary least squares with an intercept on training data. Adjusted R2, cross validated scores, and out of sample errors penalize complexity and travel better. High R2 alone never proves cause.
This page shows the formula, one full hand checked example at 20 over 100, a reference table, and practice checks that run through the tool.
How to use
- Get SSres from your regression output or hand ANOVA table.
- Get SStot as sum of squared gaps from the mean.
- Type SSres first, then SStot.
- Check that residual does not exceed total.
- Read R squared as the main decimal result.
- Read Explained percent for plain language reporting.
Formula
- SSres
- Sum of squared residuals left by the model.
- SStot
- Sum of squared gaps from the mean, above 0.
- R2
- Share of variance explained, 0 to 1 here.
If SSres is 0, R2 is 1. If SSres equals SStot, R2 is 0. Negative R2 for worse than mean fits is outside this simple tool, which stops with an error when SSres tops SStot.
Worked example
Example: SSres 20, SStot 100
A line leaves 20 residual against 100 total. Find R2.
- Write SSres = 20, SStot = 100.
- Divide: 20 / 100 = 0.2 unexplained.
- Subtract: 1 minus 0.2 = 0.8.
- Percent: 0.8 x 100 = 80.0 % explained.
- Unexplained share stays 0.2.
- Check: 0.8 + 0.2 = 1.
Reference table
| R2 | Explained | Usual note |
|---|---|---|
| 1 | 100 % | Perfect on training data |
| 0.8 | 80.0 % | Strong fit in example |
| 0.5 | 50.0 % | Half explained |
| 0 | 0 % | Mean only |
Limits
- Training fit only. Out of sample can score far lower.
- No complexity penalty. More predictors inflate R2.
- No cause proof. Correlation can ride on confounders.
- Simple 0 to 1 form. Worse than mean negatives are rejected here.
Common mistakes
- Swapping SSres with SStot, so 20/100 becomes 100/20.
- Reading 0.8 as 0.8 percent instead of 80.0 percent.
- Chasing R2 by adding junk predictors.
- Comparing R2 across different SStot bases.
- Reporting training R2 as future accuracy.
Try it yourself
Quick checks. Answers sit tucked under each question.
SSres 15, SStot 60?
R2 0.75, explained 75.0 %, unexplained 0.25.
SSres 5, SStot 200?
R2 0.975, explained 97.5 %, unexplained 0.025.
Questions
What is R squared?
1 minus residual over total. Share of variance the model explains.
What is good R2?
Depends on field. Physics wants near 1, noisy human data may prize 0.3.
Can R2 be negative?
Yes for worse than mean fits. This simple tool caps at 0 and reports an error above total.
R2 or adjusted R2?
R2 for one fit. Adjusted penalizes extra predictors for fair comparison.
Does high R2 mean cause?
No. It means fit, not mechanism.
Why 0.8 here?
20 residual over 100 total leaves 0.2 unexplained, so 0.8 explained.