Consider the the following artificial data set and its summary of the lm command:
set.seed(111)
x1=round(sort(runif(100)), 2)
x2=round(sort(runif(100)), 2)
x3=round(sort(runif(100)), 2)
y=round(1+2*x1+3*x2+4*x3+rnorm(100),1)
summary(lm(y~x1+x2+x3))
##
## Call:
## lm(formula = y ~ x1 + x2 + x3)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.35695 -0.51916 -0.05192 0.70102 2.33240
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.6556 0.1810 3.622 0.00047
## x1 1.8731 2.1465 0.873 0.38505
## x2 -4.8388 4.0227 -1.203 0.23199
## x3 12.4945 4.3210 2.892 0.00474
##
## Residual standard error: 0.8695 on 96 degrees of freedom
## Multiple R-squared: 0.9148, Adjusted R-squared: 0.9121
## F-statistic: 343.6 on 3 and 96 DF, p-value: < 2.2e-16
Use R but not the lm command to find the following numbers from the printout:
## [1] -4.8388 -2.3570 -0.5192 -0.0519 0.1810 0.6556 0.7010 0.8695 1.8731
## [10] 2.1464 2.3324 4.0226 4.3208 12.4945
Say we just found \(\pmb{\hat{\beta}}\) with k predictor variables. Now we would like to use another predictor, together with those already used. If k is large this means we have to invert a \(k+1\times k+1\) matrix. But we just inverted a very similar \(k\times k\) matrix. Show how we can make use of that.
Consider the following data set:
set.seed(1111)
x1=1:10
x2=sort(round(runif(10,0,10), 1))
y=round(2+3*x1+4*x2+rnorm(10),1)
cbind(y,x1,x2)
## y x1 x2
## [1,] 6.9 1 1.2
## [2,] 14.3 2 1.4
## [3,] 17.7 3 1.4
## [4,] 31.8 4 4.1
## [5,] 37.1 5 4.7
## [6,] 41.0 6 5.5
## [7,] 53.6 7 7.4
## [8,] 59.7 8 8.8
## [9,] 63.6 9 9.1
## [10,] 71.6 10 9.8
Use the Gram-Schmitt method to find a transformation \(\pmb{U=AX}\) such that \(\pmb{U}\) is orthogonal. Use this to verify theorem (6.3.4).