Consider a generalized linear regression problem where $EY=Z\beta$.

The Residual Sum of Squares (RSS) is $\text{RSS}:=\xi^T\xi$, where $\xi:=Y-\hat{Y}=\{I-Z(Z^TZ)^{-1}Z^T\}Y$ is the regression residual.

My first question is:

  • Why a small RSS indicates good linearity between $Y$ and $Z$?

Besides, we have:


As a result, as long as $EY$ can be written as $EY=Zf(Z)$, $E\xi$ is always zero. This means the expectation of the residual is always zero no matter linearity or non-linearity. Is this right?

Please explain by formulars.

  • $\begingroup$ It does not indicate a "good linearity" (not sure how that would be defined anyways), but a good fit. $\endgroup$ Mar 23 at 13:13
  • 2
    $\begingroup$ "Small" is meaningless. You need to compare the RSS to some measure of variation in $Y.$ That leads immediately to $R^2.$ For a discussion of that statistic, please see stats.stackexchange.com/questions/13314. For some counterpoint showing that $R^2$ nevertheless can be seen as a measure of linearity, see stats.stackexchange.com/questions/381149. $\endgroup$
    – whuber
    Mar 23 at 13:23
  • $\begingroup$ @whuber So, you are suggesting that the $R^2$ can be a measure of linearity? I am quite confused about this and Dave's answer. $\endgroup$ Mar 23 at 13:27
  • 1
    $\begingroup$ My post at stats.stackexchange.com/a/513608/919 is thorough and nuanced--it addresses that question directly. $\endgroup$
    – whuber
    Mar 23 at 13:34

1 Answer 1


It doesn't!

N <- 1000
z <- runif(N, 0, 50)
y <- 0.02*z^2 
L <- lm(y ~ z)
d <- data.frame(
  Z = z,
  Y = y
ggplot(d, aes(x = Z, y = Y)) +
  geom_point() +
    intercept = summary(L)$coef[1, 1],
    slope = summary(L)$coef[2, 1]
summary(L)$r.squared # 0.9383307

In the above example, I get $R^2>0.93$, and $R^2$ is a transformation of the residual sum of squares. While it is hard to say exactly what constitutes a good $R^2$ value or a good (small) residual sum of squares, $R^2>0.93$ is usually considered quite high, indicating a small residual sum of squares. Thus, there must be a good linear relationship between the prediction $Z$ and outcome $Y$, right? Wrong!

Quadratic shoehorned into simple linear regression

The points quite clearly do not fit a line, which is consistent with the simulation giving the relationship as being quadratic.

What a small residual sum of squares does tell you is that the predictions are generally close to the observed values. It might be that you could do better, such as fitting a quadratic term to the above regression.

This great post gives another example and further elaboration. While the question there explicitly deals with $R^2$ and not the residual sum of squares, they are functions of each other.

$$ \text{Residual Sum of Squares} =\overset{N}{\underset{i=1}{\sum}}\left( y_i-\hat y_i \right)^2\\ \text{Total Sum of Squares} = \overset{N}{\underset{i=1}{\sum}}\left( y_i-\bar y \right)^2 $$$$ R^2=1-\left(\dfrac{ \overset{N}{\underset{i=1}{\sum}}\left( y_i-\hat y_i \right)^2 }{ \overset{N}{\underset{i=1}{\sum}}\left( y_i-\bar y \right)^2 }\right)=1-\left(\dfrac{ \text{Residual Sum of Squares} }{ \text{Total Sum of Squares} }\right)\\ \Big\Updownarrow\\ \left[\text{Residual Sum of Squares}\right] = (R^2 - 1)\left[\text{Total Sum of Squares}\right] $$

  • $\begingroup$ Your example looks awfully linear to me. Why would I make such a claim in the face of an explicitly quadratic function? At stats.stackexchange.com/a/513608/919, I offer this definition: ""linearity" of an association (between either random variables or data vectors) is the degree to which their bivariate distribution is well approximated by the terms in their c.g.f. through second order." The contrast between this and my post on $R^2$ shows that we have to be careful about what we mean by "linear:" it's a subtle concept in statistics, IMHO. $\endgroup$
    – whuber
    Mar 23 at 13:24
  • $\begingroup$ @whuber I read your post. It is convincing. However, how do we explain the simulation result given by Dave? Why the $R^2$ is close to $1$ when the relation is clearly not linear? $\endgroup$ Mar 23 at 13:48
  • $\begingroup$ Because Dave is implicitly using a different concept of "linear." I can't tell what that concept is. It seems to be mathematical in nature rather than statistical. $\endgroup$
    – whuber
    Mar 23 at 13:50
  • $\begingroup$ @whuber So, basically, you are suggesting that $R^2$ is indeed a measure of ''linearity''. It's just this ''linearity'' may be different from what we mean linearity intuitively (mathematically). $\endgroup$ Mar 23 at 14:11
  • $\begingroup$ I think this post explains why Dave's simulation result gives a high $R^2$ value. $\endgroup$ Mar 23 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.