Question: Problem 6. (Residual correlation) Suppose that you build a regression model given data Y and design matrix X. We assume throughout this problem that there
Problem 6. (Residual correlation) Suppose that you build a regression model given data Y and
design matrix X. We assume throughout this problem that there is an intercept (i.e., that the first
column of X consists of all 1's).
You apply ordinary least squares and find coefficients beta^
and fitted values ^Y== X(beta^)
. Recall the
residual vector is ^r = Y- ^Y
, and that (since there is an intercept)
the sume of residuals = 0.
a) Carry out the following steps in R. First, load the GaltonFamilies dataset:
install.packages("HistData") # if you don't have the package yet
library(HistData)
data(GaltonFamilies)
Next, for the following model:
lm(data = GaltonFamilies, childHeight 1 + father)
plot the residuals against the fitted values. Compare this to a plot of the residuals against the
observed values of childHeight, and describe what patterns you see.
Some helpful R code: the residuals of a fitted model fm are obtained by using residuals(fm);
the fitted values are obtained by using fitted(fm).
b) Show that in general, ^r ^Y
= 0, so that ^r x ^Y = ^r x Y||^r||2. Using these facts, explain the patterns
seen in the plots you created in (a). (Hint: What is the sign of the sample correlation between
the residuals and the observed values?)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
