The following data were obtained in a study of the relation between diastolic blood pressure and age for boys 5 to 13 years old. We will manually implement a regression of blood pressure on age.
\(i\): | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
---|---|---|---|---|---|---|---|
age: | 5 | 8 | 11 | 7 | 13 | 12 | 6 |
pressure: | 63 | 67 | 74 | 64 | 75 | 69 | 60 |
Create the response vector in R, call it y
.
Create the design matrix in R, call it X
.
Calculate the OLS estimates from a regression of pressure on age using matrix multiplication in R. Call this vector betahat
.
Calculate the fitted values from the above defined quantities. Call this vector yhat
.
Calculate the residuals from the above defined quantities. Call this vector e
.
Calculate the MSE from the above defined quantities. Call this value mse
.
Calculate the standard errors of \(\hat{\mathbf{\beta}}\) from the above quantities.
Verify all of your calculations above using lm()
.