R-squared
R-squared is the proportion of the variation in y that the regression line explains: R^2 = 1 - SSE / SST, where SSE is the sum of squared residuals and SST the total sum of squares. In simple regression it equals the squared correlation coefficient, and it runs from 0 to 1.
Syntax
R^2 = 1 - SSE / SST = SSR / SST| Part | What it is |
|---|---|
SST | sum of (y - y-bar)^2, the total variation in y |
SSE | sum of (y - y-hat)^2, the variation left in the residuals |
SSR | SST - SSE, the variation explained by the line |
Examples
y: 2, 4, 5, 4, 5 (y-bar = 4), fitted line y-hat = 2.2 + 0.6x
SST = 4 + 0 + 1 + 0 + 1 = 6
residuals: -0.8, 0.6, 1.0, -0.6, -0.2; SSE = 0.64 + 0.36 + 1 + 0.36 + 0.04 = 2.4
R^2 = 1 - 2.4 / 6Result: 0.6
Excel: =RSQ(B1:B5, A1:A5)
From the correlation: r = 0.775
r^2Result: 0.6
Perfect fit: y = 2x exactlyResult: R^2 = 1 (SSE = 0)
Common mistakes
- Treating a high R-squared as proof the model is right; a curved relationship can still have R^2 = 0.9 with a badly biased line, so look at the residual plot.
- Comparing R-squared across models with different numbers of predictors; adding any variable raises R^2, so use adjusted R-squared.
- Reading R^2 = 0.6 as 60% of the points on the line; it is 60% of the variance, not of the points.
Practice R-squared
These drills check your answer on live data, free, no account needed.
- R squaredData on monthly ad spend and sales at regional stores (x = Ad spend ($k), y = Sales ($k)): (9, 87.8), (10, 98.7), (6, 81.3), (12, 99.1), (15, 111.9), (6, 78.6). What share of the variation in y does the least squares line explain? Give R² as a decimal. Round to 3 decimal places.
Questions
What is a good R-squared value?
It depends on the field. Physical measurements often give 0.95 or more; human behavior data rarely passes 0.3. Judge it against what is typical for your problem, and against the prediction error you need.
Can R-squared be negative?
Not for an ordinary least squares fit with an intercept. It can be negative for a model forced through the origin or a model evaluated on new data, meaning it predicts worse than the mean.
What is adjusted R-squared?
R-squared penalized for the number of predictors: 1 - (1 - R^2)(n - 1) / (n - k - 1). It only rises when a new variable improves the fit more than chance would.
Related
- Linear regressionHow to fit a regression line y = a + bx: slope b = Sxy / Sxx, intercept a = y-bar - b x-bar, a worked example, prediction and Excel SLOPE and INTERCEPT.
- Correlation coefficient (Pearson r)How to calculate the Pearson correlation coefficient r by hand and with Excel CORREL, a worked example with exact numbers and what values of r mean.
- ResidualsA residual is observed y minus predicted y. How to compute residuals from a fitted line, a worked example, and residual plot patterns that signal a bad model.
- VarianceHow to calculate variance step by step, why the sample version divides by n - 1, how it relates to standard deviation, and Excel VAR.S and VAR.P.