R-Squared Calculator
- From the summary sums, the correlation numerator is n x Sxy - Sx x Sy = 5 x 66.00 - 15.00 x 20.00 = 30.00.
- The denominator is sqrt((5 x 55.00 - 15.00^2) x (5 x 86.00 - 20.00^2)) = sqrt(50.00 x 30.00) = 38.73.
- r = 30.00 / 38.73 = 0.7746, and R-squared is r squared: 0.6000.
- So the straight line explains 60.00% of the variance in y and leaves 40.00% unexplained.
- Adjusted R-squared penalizes the single predictor on 5 points: 1 - (1 - 0.6000) x (5 - 1) / (5 - 2) = 0.4667 — with tiny samples it can even turn negative, which simply means the line fits worse than the mean.
This r squared calculator takes the summary sums you already have — n, Σx, Σy, Σxy, Σx², and Σy² — and returns R-squared, the square of the Pearson correlation coefficient. R-squared reads as the share of variance in y that a straight line in x accounts for: R² = 0.60 means 60% explained, 40% left over. The calculator also reports adjusted R², which penalizes the fit for the number of predictors relative to the sample size. With one predictor, adjusted R² equals 1 - (1 - R²)(n - 1)/(n - 2). It can go negative when the line fits worse than the mean, and a negative adjusted R² is not an error: it is the statistic reporting that the model underperforms predicting the mean of y for every point. With five observations, sampling noise is large: a worked example's R² of 0.6000 shrinks to an adjusted 0.4667, which is the honest number to quote at that size.
The underlying method uses the standard Pearson formula, r = (nΣxy - ΣxΣy) / sqrt((nΣx² - (Σx)²)(nΣy² - (Σy)²)), then squares the result. This is the accepted standard because it works directly from the summary sums a textbook problem or a spreadsheet's intermediate output provides, avoiding the need for raw data. R² says nothing about causation, and a high R² can decorate a curved relationship forced through a straight line — Anscombe's quartet is the standing warning. This page shows the formula, step-by-step workings, worked examples, and sources.
Worked examples
Textbook moderate fit
Primary result: 0.6000 — r = 0.7746, so the line explains 60.00% of the variance — adjusted down to 0.4667 on five points. (5 · 15 · 20 · 66 · 55 · 86)
| R-squared (coefficient of determination) | 0.6000 |
| Correlation coefficient (r) | 0.7746 |
| Adjusted R-squared | 0.4667 |
| Variance explained | 60.00% |
Perfect linear fit
Primary result: 1.0000 — Every point on the line: r and R² both print 1.0000. (4 · 10 · 24 · 70 · 30 · 164)
| R-squared (coefficient of determination) | 1.0000 |
| Correlation coefficient (r) | 1.0000 |
| Adjusted R-squared | 1.0000 |
| Variance explained | 100.00% |
Weak relationship
Primary result: 0.0571 — R² of 0.0571 with a negative adjusted figure — the line fits worse than the mean. (6 · 21 · 60 · 212 · 91 · 604)
| R-squared (coefficient of determination) | 0.0571 |
| Correlation coefficient (r) | 0.2390 |
| Adjusted R-squared | -0.1786 |
| Variance explained | 5.71% |
How R-squared is calculated from summary sums
The r squared calculator on this page works from the six summary sums that a textbook problem or a spreadsheet's intermediate output typically provides: n, Σx, Σy, Σxy, Σx², and Σy². These sums come straight from raw data. For each observation you have an x value and a y value. The count of paired observations gives n. Adding every x value gives Σx, and adding every y value gives Σy. Multiplying each x by its paired y and adding those products gives Σxy. Squaring each x value and adding them gives Σx², and squaring each y value and adding them gives Σy². Once you have these six sums, the calculator computes the Pearson correlation coefficient r using the formula r = (nΣxy - ΣxΣy) / sqrt((nΣx² - (Σx)²)(nΣy² - (Σy)²)), then squares r to obtain R-squared.
Consider a worked example with five observations. Suppose the six summary sums are n = 5, Σx = 15, Σy = 20, Σxy = 68, Σx² = 55, and Σy² = 90. The numerator of r is nΣxy - ΣxΣy, which equals 5 × 68 - 15 × 20 = 340 - 300 = 40. The denominator is the square root of the product of two terms. The first term is nΣx² - (Σx)² = 5 × 55 - 15² = 275 - 225 = 50. The second term is nΣy² - (Σy)² = 5 × 90 - 20² = 450 - 400 = 50. Multiplying these gives 50 × 50 = 2500, and the square root of 2500 is 50. So r = 40 / 50 = 0.8000, and R² = 0.8000² = 0.6400.
However, R-squared is the square of the Pearson correlation coefficient and reads as the share of variance in y that a straight line in x accounts for. An R² of 0.60 means 60% explained, 40% left over. In this worked example, R² = 0.6400 means 64% of the variance in y is explained by the linear relationship with x, while 36% remains unexplained. That said, with only five observations, sampling noise is large. The worked example's R² of 0.6000 shrinks to an adjusted 0.4667, which is the honest number to quote at that sample size. Adjusted R² penalizes the fit for the number of predictors relative to the sample size. With one predictor, adjusted R² is 1 - (1 - R²)(n - 1)/(n - 2). A negative adjusted R² is not an error: it is the statistic reporting that the model underperforms predicting the mean of y for every point.
R² says nothing about causation, and a high R² can decorate a curved relationship forced through a straight line. Anscombe's quartet is the standing warning: four datasets can share the same R² yet look completely different when graphed. The six summary sums give you the number, but plotting the raw data tells you whether a straight line is the right shape in the first place.
R² vs adjusted R²
R-squared is the square of the Pearson correlation coefficient and reads as the share of variance in y that a straight line in x accounts for: R² = 0.60 means 60% explained, 40% left over. That reading is honest as far as it goes, but it has a blind spot. Every time you add a predictor, R² can only stay the same or go up, even if the new variable is pure noise. Adjusted R² exists to correct that optimism. It penalizes the fit for the number of predictors relative to the sample size, so a model has to earn its score rather than inflate it by piling on variables.
With one predictor, the adjustment takes a specific form. The formula is 1 - (1 - R²)(n - 1)/(n - 2), where n is the number of observations. The numerator (n - 1) and denominator (n - 2) reflect the degrees of freedom available before and after estimating the line's slope. When the sample is large, the ratio (n - 1)/(n - 2) sits close to 1, so the penalty is small and adjusted R² stays near R². When the sample is small, the ratio grows and the penalty bites harder. The adjusted value can even go negative when the line fits worse than the mean. A negative adjusted R² is not an error: it is the statistic reporting that the model underperforms predicting the mean of y for every point.
A concrete example shows why this matters. With five observations, sampling noise is large: the worked example's R² of 0.6000 shrinks to an adjusted 0.4667, which is the honest number to quote at that size. The unadjusted figure says 60% of variance is explained, but with only five data points and one predictor, that claim rests on very little evidence. The adjusted value of 0.4667 tells a more cautious story: after accounting for the one degree of freedom the slope consumed, the fit explains closer to 47% of the variance. Anyone using an r squared calculator on a small dataset should report both numbers and lean on the adjusted one when the sample is thin.
Neither statistic settles the deeper questions. R² says nothing about causation, and a high R² can decorate a curved relationship forced through a straight line — Anscombe's quartet is the standing warning. Four datasets can share the same R² while looking completely different, which is why a single number never substitutes for plotting the data and checking whether a straight line is the right shape in the first place.
What R² does and does not tell you
Think of R² as bookkeeping for variance, not as a stamp of truth. Because R-squared is the square of the Pearson correlation coefficient, it reads as the share of variance in y that a straight line in x accounts for: R² = 0.60 means 60% explained, 40% left over. That framing is useful, but it can also mislead. A high value tells you a line captures a lot of the spread in y; it does not tell you the relationship is truly linear, that it is causal, or that your data are free from distortions.
Curvature, outliers, and range restriction can each inflate or deflate R² while hiding the real story in the data. A strongly curved relationship forced through a straight line can still produce an impressive-looking value, because the line picks up the overall trend even though it systematically misses the shape. A single outlier can drag the line and the statistic in a direction the rest of the data do not support. Restricting the range of x shrinks the apparent association, sometimes dramatically, because you have removed the variation that lets the relationship show itself. The standing warning here is Anscombe's quartet: four datasets with nearly identical R² values and other summary statistics, yet wildly different scatterplots. It is the cautionary exhibit for anyone tempted to quote a number without plotting the data first.
R² says nothing about causation. A high value can decorate a curved relationship forced through a straight line, and two variables can move together for reasons that have nothing to do with one causing the other. The statistic measures co-movement along a line, full stop. If your question is whether x causes y, R² cannot answer it.
Sample size matters as much as shape. With five observations, sampling noise is large: the worked example's R² of 0.6000 shrinks to an adjusted 0.4667, which is the honest number to quote at that size. Adjusted R² penalizes the fit for the number of predictors relative to the sample size; with one predictor it is 1 - (1 - R²)(n - 1)/(n - 2), and it can go negative when the line fits worse than the mean. A negative adjusted R² is not an error: it is the statistic reporting that the model underperforms predicting the mean of y for every point.
Reading R² in the wild
A common question on any r squared calculator is whether the result is 'good.' The honest answer is that a single threshold for good is a category error, because what counts as a strong fit depends entirely on the field and the data. R-squared is the square of the Pearson correlation coefficient and reads as the share of variance in y that a straight line in x accounts for: R² = 0.60 means 60% explained, 40% left over. That number means one thing in a controlled lab and something very different in a noisy survey.
In physics and engineering, where instruments are precise and theory predicts a tight relationship, R² values above 0.95 are routine and expected. A fit below 0.90 there might prompt a researcher to check the equipment. In psychology and the social sciences, where human behavior introduces layers of unmeasured variation, an R² of 0.30 or 0.40 can be a meaningful and publishable result. A blanket rule like 'R² above 0.70 is good' treats both settings as if they share the same standard, which they do not. The number is only as strong as the context that produced it.
Sample size matters as much as field convention. Adjusted R² penalizes the fit for the number of predictors relative to the sample size; with one predictor it is 1 - (1 - R²)(n - 1)/(n - 2), and it can go negative when the line fits worse than the mean. A negative adjusted R² is not an error: it is the statistic reporting that the model underperforms predicting the mean of y for every point. With five observations, sampling noise is large: the worked example's R² of 0.6000 shrinks to an adjusted 0.4667, which is the honest number to quote at that size. Quoting the unadjusted R² at small n overstates the fit.
Finally, R² says nothing about causation, and a high R² can decorate a curved relationship forced through a straight line. Anscombe's quartet is the standing warning: four datasets can share the same R² while looking completely different when plotted. A number alone never tells you whether the relationship is linear, causal, or even visually sensible. Read R² alongside the scatterplot, the sample size, and the field's conventions, not as a verdict.
- Physics and engineering: R² above 0.95 is routine; below 0.90 may signal a problem.
- Psychology and social science: R² of 0.30 to 0.40 can be meaningful given natural variation.
- Small samples: adjusted R² is the honest number to quote, not the raw R².
- Any field: plot the data first, because a high R² can mask a curved or non-causal relationship.
FAQs
What is R-squared?
R-squared is the proportion of the variance in a dependent variable that a regression line explains. It is equal to the square of the correlation coefficient r. This makes it a straightforward way to summarize how well a linear model captures the variation in your data.
How do I calculate R-squared from summary statistics?
First compute r from the sums: r = (nΣxy - ΣxΣy) / sqrt((nΣx² - (Σx)²)(nΣy² - (Σy)²)). Then square it. The result is your R-squared value. This approach works when you have summary statistics rather than raw data pairs.
What does an R² of 0.60 mean?
An R² of 0.60 means the line accounts for 60% of the variation in y. The remaining 40% is due to other factors and noise. In other words, the model explains a majority of the variability, but a substantial portion still falls outside what the line captures.
What is adjusted R-squared?
Adjusted R-squared is R² corrected for the number of predictors and the sample size. It only rises when a predictor earns its place, and it can be negative for a model worse than the mean. This makes it more reliable than plain R² when comparing models with different numbers of predictors.
Can R-squared be negative?
Plain R² from a fitted line cannot be negative, but adjusted R² can. When adjusted R² is negative, it means the model predicts worse than simply using the mean of y. This situation signals that the predictors added to the model are not improving the fit beyond a baseline.
Does a high R² prove causation?
No. R² measures linear association in the sample, not a cause-and-effect relationship. Causation needs design, not a fit statistic. A high R² only tells you that the variables move together in a predictable way within your data, so you must rely on study design to establish causation.