Turn predictions, sums of squares or a reported value into R squared, adjusted R squared and an F test, and see why Excel RSQ and scikit-learn r2_score disagree on the same data.
R Squared Calculator - Adjusted R Squared and F Test
Turn predictions, sums of squares or a reported value into R squared, adjusted R squared and an F test, and see why Excel RSQ and scikit-learn r2_score disagree on the same data.
Parameters
Enter data for calculations
💡 Fill in all required fields to unlock the calculate button
R squared from predictions, from sums of squares, or adjusted from a reported value
Three starting points lead to the same number. Actual and predicted values, as scikit-learn's r2_score takes them; the two sums of squares from an ANOVA table or a homework question; or an R squared already printed somewhere that you want to adjust for the number of predictors and test. From the pairs 3, -0.5, 2, 7 and their predictions 2.5, 0, 2, 8 the calculator gives R squared 0.9486, while Excel's RSQ on the same pairs says 0.9700, and it explains the difference. Around the headline number you also get adjusted R squared, the overall F test with its p-value, the smallest R squared that would be significant for your n and k, RMSE, MAE, MAPE, the mean error and the pairs that carry most of the error.
R squared on its own, and R squared with context
A single number
- 0.40 from 12 observations and 8 predictors looks respectable, though adjusted it is -1.2000
- predictions that are all 5 units too high can still show RSQ = 1.0000
- nobody can tell whether 0.40 is significant without n and k
- one bad pair can carry two thirds of the error unnoticed
What the calculator adds
- adjusted R squared and the shrinkage it reveals
- R squared and RSQ side by side, with a note when they part ways
- the overall F test, its p-value and the R squared needed to pass at 0.05
- the five largest errors with their share of SSE
Three starting points and the boxes each one needs
- What do you have - actual and predicted values, the sums of squares SSE and SST, or an R squared you want to adjust. Only the boxes for that choice appear, and values left in hidden boxes are ignored.
- Actual and predicted values - two lists in the same order, separated by spaces, commas or new lines, with a dot for decimals and no thousands separators. The third prediction must belong to the third observation.
- SSE and SST - the sum of squared errors (residual sum of squares) and the total sum of squares around the mean. If your table shows the regression sum SSR instead, SSE = SST - SSR.
- R squared - as a decimal: 72% is 0.72. A value above 1 is refused with the decimal it probably meant.
- Number of observations n and predictors k - k counts the explanatory variables without the intercept, so a simple regression has 1. Both are needed for adjusted R squared and the F test.
- Read the result: R squared first, then the tiles, any note about a gap between R squared and RSQ, a negative adjusted value or a small sample, and the error table.
The formulas, with three results worked out
adjusted R squared = 1 - (1 - R squared)(n - 1) / (n - k - 1)
F = (R squared / k) / ((1 - R squared) / (n - k - 1)), on k and n - k - 1 degrees of freedom
What predictors cost: one R squared of 0.40, five study designs
The same R squared means very different things depending on how many observations paid for how many predictors. Each row is the calculator's output for R squared = 0.40.
| Design | Adjusted | Shrinkage | p (F test) | R squared needed at 0.05 |
|---|---|---|---|---|
| n = 100, k = 1 | 0.3939 | 0.0061 | below 0.0001 | 0.0386 |
| n = 30, k = 1 | 0.3786 | 0.0214 | 0.0002 | 0.1303 |
| n = 30, k = 5 | 0.2750 | 0.1250 | 0.0236 | 0.3532 |
| n = 15, k = 5 | 0.0667 | 0.3333 | 0.3817 | 0.6592 |
| n = 12, k = 8 | -1.2000 | 1.6000 | 0.9481 | 0.9593 |
Going from one predictor to five on the same 30 observations costs 0.1036 of adjusted R squared (0.3786 down to 0.2750) without changing R squared at all. The last row is the classic overfitted model: eight predictors on twelve points leave three degrees of freedom, and even an R squared of 0.95 would not reach significance there.
Excel, Python and R: which function prints which R squared
Two definitions circulate under one name. The table shows which one each common tool reports, so you know which of the calculator's figures to compare against.
| Tool | What it computes | Matches this calculator's |
|---|---|---|
| Excel RSQ, numpy corrcoef squared | square of Pearson's r between the two lists | squared correlation tile |
| scikit-learn r2_score | 1 - SSE / SST, can be negative | main R squared |
| Excel LINEST with stats, chart trendline | R squared of the fitted least-squares line | both, which agree for an in-sample fit with an intercept |
| R summary(lm), statsmodels | Multiple R-squared and Adjusted R-squared, plus the F statistic | R squared, adjusted R squared, F and p |
| R lm without an intercept (y ~ x - 1) | compares SSE with the sum of squares around zero, not the mean | neither; expect a higher figure from R |
Asked about R squared, in short
Related tools
Z-Score Calculator
Turns an F or t result into a percentile or a two-tailed p on the normal curve - See calculator
Linear Regression Calculator
Fits the least-squares line and prints R squared with the slope test - See calculator
Pearson Correlation Calculator
r with its p-value and interval, the square root behind RSQ - See calculator
Coefficient of Variation Calculator
Puts RMSE in context as a share of the mean - See calculator
Skewness Calculator
Paste the errors to see whether the model misses more often in one direction - See calculator
Standard Deviation Calculator
Spread of the actual values, the yardstick for RMSE - See calculator