R-squared vs standard deviation of residuals

By Jude Wallis · Published

R-squared is the proportion of the variation in the response that the regression line explains, a unitless number from 0 to 1. The standard deviation of the residuals, ss, is the typical distance between an observed value and the line's prediction, in the units of the response.

AP Statistics: Unit 5 (topics 5.4 Residuals, 5.5 Least-Squares Regression). The coefficient of determination is interpreted in topic 5.5 and residuals are topic 5.4, both in Unit 5 of the Fall 2026 AP Statistics course. The standard deviation of the residuals is standard regression vocabulary that appears as S on computer output. The framework's topic titles do not name it, so treat that half as general statistics background.

R-squared vs s: the short answer

Both numbers describe how well a least-squares line fits, and both are built from the residuals, the differences y−y^y - \hat{y} between observed and predicted values. They answer different questions.

R-squared, written r2r^2, is relative. It compares the line's misses with the misses you would make by ignoring xx and predicting the mean yˉ\bar{y} ("y-bar") for everyone. It reports the fraction of the variation in yy that the line accounts for.

The standard deviation of the residuals, written ss, is absolute. It reports the typical size of a prediction error, in the same units as yy.

A line can explain 98% of the variation and still miss by an amount that matters, or explain 50% and miss by an amount too small to care about. The two are reported together because each leaves out what the other shows.

What r-squared measures

The coefficient of determination is

r2=1−∑(y−y^)2∑(y−yˉ)2r^2 = 1 - \frac{\sum (y - \hat{y})^2}{\sum (y - \bar{y})^2}

The top of the fraction is the sum of squared residuals from the line. The bottom is the sum of squared deviations of yy from its mean, the total variation in the response. The fraction is the share of variation the line leaves unexplained, and r2r^2 is the rest.

For a least-squares line, r2r^2 equals the square of the correlation rr. It has no units and lies between 0 and 1. The standard interpretation: about r2×100r^2 \times 100 percent of the variation in the response is explained by the linear relationship with the explanatory variable.

Changing the units of either variable leaves r2r^2 unchanged. That makes it easy to compare across data sets and impossible to read as a prediction error. What counts as a high value depends on the field, as what is a good r-squared value explains.

What the standard deviation of the residuals measures

The standard deviation of the residuals is

s=∑(y−y^)2n−2s = \sqrt{\frac{\sum (y - \hat{y})^2}{n - 2}}

It uses the same sum of squared residuals as r2r^2, divides by n−2n - 2, and takes the square root, which returns the result to the units of yy. The interpretation: the actual response values typically differ from the values predicted by the line by about ss.

Because it carries units, ss can be judged against what matters in context. A typical miss of 2 points on a 100-point test is small. A typical miss of 2 grade levels in reading is large. The value is a typical miss, so individual residuals can be larger.

Changing the units of yy changes ss by the same factor. Convert the response from centimeters to millimeters and ss is multiplied by 10. Regression output usually prints it as S.

The differences side by side

FeatureR-squared (r2r^2)Standard deviation of residuals (ss)
What it reportsProportion of variation in yy explained by the lineTypical size of a prediction error
UnitsNoneUnits of yy
Possible values0 to 10 or greater, no upper limit
A better fit meansA larger valueA smaller value
Compares the line withPredicting yˉ\bar{y} for every caseNothing, it is an absolute size
Effect of changing the units of yyNoneScales with the units
Formula1−∑(y−y^)2∑(y−yˉ)21 - \frac{\sum (y - \hat{y})^2}{\sum (y - \bar{y})^2}∑(y−y^)2n−2\sqrt{\frac{\sum (y - \hat{y})^2}{n - 2}}

Both equal their best value when every point is exactly on the line: r2=1r^2 = 1 and s=0s = 0.

How the two are linked

Both formulas contain the sum of squared residuals, so one can be written in terms of the other. With sys_y as the ordinary standard deviation of the response values,

s=sy(1−r2)⋅n−1n−2s = s_y \sqrt{(1 - r^2) \cdot \frac{n - 1}{n - 2}}

This shows why neither number can stand in for the other. The value of ss depends on r2r^2 and on sys_y, how spread out the response values are to begin with. Two data sets of the same size with the same r2r^2 have different ss whenever their responses have different spreads. Two data sets of the same size with the same ss have different r2r^2 whenever one has more total variation for the line to explain.

For reasonably large nn the last fraction is close to 1, so ss is roughly sy1−r2s_y \sqrt{1 - r^2}. With r2=0.75r^2 = 0.75, that is sy0.25=0.5sys_y \sqrt{0.25} = 0.5 s_y: a line that explains 75% of the variation cuts the typical prediction error only in half.

The classic mix-up and how to avoid it

The first error is reading r2r^2 as accuracy. "r2=0.85r^2 = 0.85, so predictions are 85% accurate" and "85% of the points are on the line" are both wrong. The value 0.85 is a share of variation and says nothing in the units of the response. For the size of prediction errors, use ss.

The second error is interpreting ss without units or without the word typical. Write a full sentence in context, such as: the actual heights typically differ from the heights predicted by the line by about 1.73 centimeters.

The third error is treating either number as a check on whether a line is the right model. Curved data can produce a high r2r^2 and a small ss. The residual plot answers that question, as covered in how to interpret residual plots.

On computer output, keep three lines apart: S is the standard deviation of the residuals, R-Sq is r2r^2, and the correlation rr is often not printed. When it is missing, you get rr by taking the square root of r2r^2 and attaching the sign of the slope.

Computing both from the same residuals

A plant's height in centimeters is recorded for six weeks. For weeks 1 through 6 the heights are 13, 12, 17, 19, 18, and 23. The least-squares line is y^=10+2x\hat{y} = 10 + 2x. Find r2r^2 and ss, and interpret each.

  1. Compute the predicted heights from y^=10+2x\hat{y} = 10 + 2x for x=1x = 1 through 6: 12, 14, 16, 18, 20, 22.

  2. Compute the residuals, observed minus predicted: 13−12=113 - 12 = 1, 12−14=−212 - 14 = -2, 17−16=117 - 16 = 1, 19−18=119 - 18 = 1, 18−20=−218 - 20 = -2, 23−22=123 - 22 = 1. They sum to 0.

  3. Square and add the residuals: 1+4+1+1+4+1=121 + 4 + 1 + 1 + 4 + 1 = 12.

  4. Find the mean height: yˉ=13+12+17+19+18+236=1026=17\bar{y} = \frac{13 + 12 + 17 + 19 + 18 + 23}{6} = \frac{102}{6} = 17.

  5. Find the total variation. The deviations from 17 are -4, -5, 0, 2, 1, 6, and their squares sum to 16+25+0+4+1+36=8216 + 25 + 0 + 4 + 1 + 36 = 82.

  6. Compute r2=1−1282≈1−0.146=0.854r^2 = 1 - \frac{12}{82} \approx 1 - 0.146 = 0.854.

  7. Compute s=126−2=3≈1.73s = \sqrt{\frac{12}{6 - 2}} = \sqrt{3} \approx 1.73 centimeters.

r2≈0.854r^2 \approx 0.854: about 85.4% of the variation in height is explained by the linear relationship with week. s≈1.73s \approx 1.73 centimeters: the actual heights typically differ from the heights the line predicts by about 1.73 centimeters.

Same s, different r-squared

A second plant is measured over the same six weeks, with heights 17, 20, 29, 35, 38, and 47 centimeters and least-squares line y^=10+6x\hat{y} = 10 + 6x. Find r2r^2 and ss for this plant and compare them with the first plant's values of 0.854 and 1.73 centimeters.

  1. Compute the predicted heights from y^=10+6x\hat{y} = 10 + 6x: 16, 22, 28, 34, 40, 46.

  2. Compute the residuals: 17−16=117 - 16 = 1, 20−22=−220 - 22 = -2, 29−28=129 - 28 = 1, 35−34=135 - 34 = 1, 38−40=−238 - 40 = -2, 47−46=147 - 46 = 1. These are the same six residuals as the first plant, so their squares again sum to 12.

  3. Compute s=124=3≈1.73s = \sqrt{\frac{12}{4}} = \sqrt{3} \approx 1.73 centimeters, the same as before.

  4. Find the mean height: yˉ=17+20+29+35+38+476=1866=31\bar{y} = \frac{17 + 20 + 29 + 35 + 38 + 47}{6} = \frac{186}{6} = 31.

  5. Find the total variation. The deviations from 31 are -14, -11, -2, 4, 7, 16, and their squares sum to 196+121+4+16+49+256=642196 + 121 + 4 + 16 + 49 + 256 = 642.

  6. Compute r2=1−12642≈1−0.019=0.981r^2 = 1 - \frac{12}{642} \approx 1 - 0.019 = 0.981.

  7. Compare. The line misses by the same typical amount for both plants. The second plant grew much more over the six weeks, so there was far more variation in height to explain, and the same misses are a smaller share of it.

For the second plant r2≈0.981r^2 \approx 0.981 and s≈1.73s \approx 1.73 centimeters. Its r2r^2 is higher than the first plant's 0.854, yet predictions from the two lines are equally precise, with a typical error of 1.73 centimeters in both. A higher r2r^2 does not by itself mean smaller prediction errors.

Frequently asked questions

Does a higher r-squared always mean a smaller s?

Only when the comparison is within the same response data. Across different data sets it does not, because ss also depends on how spread out the response values are. Two lines can have the same ss with different r2r^2, or the same r2r^2 with different ss.

Why does the formula for s divide by n minus 2?

Fitting a line estimates two quantities from the data, the slope and the intercept. Dividing by n−2n - 2 instead of nn accounts for that. With only two points the line passes through both, every residual is 0, and ss cannot be computed.

Which one should I use to describe how good my predictions are?

Use ss for the size of prediction errors, because it is in the units of the response and can be compared with what matters in context. Use r2r^2 to describe how much of the variation in the response the line accounts for. Check a residual plot before trusting either.