STAT 306 - Module 06
There’s no guarantee that the model assumptions are reasonable for the data at hand.
Using \(Y\) to check the assumptions is hard because \(Y\) contains both the signal (the linear part) and the noise (the errors).
But if the model is appropriate (i.e., the assumptions are reasonable), then the errors \(\varepsilon_i\) should behave like i.i.d. observations from \(N(0,\sigma^2)\).
Unfortunately, the errors are not observable, so we use the residuals \(e_i\) as a proxy for the errors \(\varepsilon_i\).
\[ \sum_{i=1}^n e_i = 0 \;. \]
\[ \sum_{i=1}^n x_i e_i = 0 \;. \]
Residuals are often used for model diagnostics, i.e., to assess how well the model fits the data.
Several model diagnostic methods use plots to graphically determine if the observed residuals behave in ways that differ from how they should behave (in theory) under the model assumptions.
Some common plots include:


Scroll down


Scroll down


Scroll down
The normality assumption for the errors can be checked using a normal quantile plot of the residuals.
A normal quantile plot (sometimes called a normal probability plot) plots the ordered residuals \(e_{(1)}\leq\dotsc\leq e_{(n)}\) against \(\mathbb{E}[Z_{(1)}]\leq\dotsc\leq \mathbb{E}[Z_{(n)}]\), where \(Z_{(1)}\leq\dotsc\leq Z_{(n)}\) are an ordered sample of size \(n\) from \(N(0,1)\).
If the distribution of the residuals is close to normal, then the residual quantiles should resemble the expected quantiles, and so the points in the plot should lie closely along a straight line that has an intercept of \(0\) and a slope of \(\sigma\).



When the covariate represents (most commonly) discrete time points, serial correlation (or more generally, autocorrelation) refers to the correlations in the responses across time points.
If there is no serial correlation, then plotting sequential residuals \(e_{i+1}\) against \(e_i\) should show no obvious patterns.


Based on the diagnostic plots, which of the following is the primary conclusion about this regression model?

Based on the diagnostic plots, which of the following is the primary conclusion about this regression model?

Based on the diagnostic plots, which of the following is the primary conclusion about this regression model?

Based on the diagnostic plots, which of the following is the primary conclusion about this regression model?

Based on the diagnostic plots, which of the following is the primary conclusion about this regression model?

Based on the diagnostic plots, which of the following is the primary conclusion about this regression model?

Based on the diagnostic plots, which of the following is the primary conclusion about this regression model?

Based on the diagnostic plots, which of the following is the primary conclusion about this regression model?

Based on the diagnostic plots, which of the following is the primary conclusion about this regression model?

Based on the diagnostic plots, which of the following is the primary conclusion about this regression model?

Based on the diagnostic plots, which of the following is the primary conclusion about this regression model?

Based on the diagnostic plots, which of the following is the primary conclusion about this regression model?

Show that \[\sum_{i=1}^n (Y_i-\bar{Y})^2 = \sum_{i=1}^n (\hat{Y}_i - \bar{Y})^2 + \sum_{i=1}^n (Y_i-\hat{Y}_i)^2\]
What does each of the three terms represent?
\[ \begin{align} \sum_{i=1}^n (Y_i-\bar{Y})^2 &= \sum_{i=1}^n (Y_i-\hat{Y}_i + \hat{Y}_i - \bar{Y})^2\\ &= \sum_{i=1}^n (\hat{Y}_i - \bar{Y})^2 + \sum_{i=1}^n (Y_i-\hat{Y}_i)^2 + 2\sum_{i=1}^n (Y_i-\hat{Y}_i)(\hat{Y}_i - \bar{Y})\\ &= \sum_{i=1}^n (\hat{Y}_i - \bar{Y})^2 + \sum_{i=1}^n (Y_i-\hat{Y}_i)^2 \end{align} \]
True or False: A high \(R^2\) means our model is a good fit.
True or False: A high \(R^2\) means our model is a good fit.
True or False: A high \(R^2\) means that our predictions will be accurate.
True or False: A high \(R^2\) means that our predictions will be accurate.
True or False: A \(R^2 \approx 0\) means \(X\) and \(Y\) are not related.
True or False: A \(R^2 \approx 0\) means \(X\) and \(Y\) are not related.
Solution:
We want to prove that \(R^2 = r^2\). We start with the definition \(R^2 = \frac{MSS}{TSS}\). Let \(S_{xx} = \sum (x_i - \bar{x})^2\), \(S_{yy} = \sum (y_i - \bar{y})^2\), and \(S_{xy} = \sum (x_i - \bar{x})(y_i - \bar{y})\). Then,
\[ \begin{align*} R^2 &= \frac{MSS}{TSS} \\ &= \frac{\sum(\hat{y}_i - \bar{y})^2}{S_{yy}} \\ &= \frac{\sum(\bar{y}+\hat{\beta}_1(x_i - \bar{x})-\bar{y})^2}{S_{yy}} \\ &= \frac{\sum(\hat{\beta}_1(x_i - \bar{x}))^2}{S_{yy}} \\ &= \frac{\hat{\beta}_1^2 \sum(x_i - \bar{x})^2}{S_{yy}} \\ &= \frac{\hat{\beta}_1^2 S_{xx}}{S_{yy}} \\ &= \frac{(S_{xy}/S_{xx})^2 S_{xx}}{S_{yy}} \\ &= \frac{S_{xy}^2}{S_{xx}S_{yy}} \\ &= \left(\frac{S_{xy}}{\sqrt{S_{xx}S_{yy}}}\right)^2 \\ &= r^2 \end{align*} \]
body mass based on the bill depth.
Call:
lm(formula = body_mass_g ~ bill_depth_mm, data = penguins_clean)
Coefficients:
(Intercept) bill_depth_mm
7520 -193

species, the correlation between bill depth and body mass becomes positive.We keep saying that we assume a linear relationship between \(X\) and \(Y\).
The linearity assumption is linear in the parameters. For example:
We can just think of \(Z = X\), \(Z = X^2\), \(Z = \log(X)\), \(Z = e^X\), etc., and then fit a linear model of the form \[ Y_i = \beta_0 + \beta_1 Z_i + \varepsilon_i \]
The model is not linear if it includes terms like \(\sin(\beta_1 X)\).


Residual Diagnostics: We cannot observe the errors \(\varepsilon_i\), so we use the residuals \(e_i\) as a proxy to check the model assumptions.
What to Look for in the Plots:
Sum of Squares Decomposition: For least squares with an intercept, \[ \underbrace{\sum_{i=1}^n (Y_i-\bar{Y})^2}_{TSS} = \underbrace{\sum_{i=1}^n (\hat{Y}_i - \bar{Y})^2}_{MSS} + \underbrace{\sum_{i=1}^n (Y_i-\hat{Y}_i)^2}_{RSS} \]
Coefficient of Determination: \(R^2 = \dfrac{MSS}{TSS} = 1 - \dfrac{RSS}{TSS}\) is the proportion of the variability in \(Y\) explained by the linear model.
Linearity and Simpson’s Paradox:
species) can reverse the direction of an association.© 2025 Rodolfo Lourenzutti – Material Licensed under CC By-SA 4.0