2
111111111111111111111111111111111111111111111111111111111111111111111111111 Please can you help me to solve this problem. It should be calculated by vectorization. The question is:
The i-th deletion residual $e_{(-i)}$ is defined as $e_{(-i)} = y_i - X^\top B_{(-i)}$
where $(X^\top)$ is the i-th row of the design matrix $X$ and $B_{(-i)}$ is a column vector of least square parameter estimates calculated without the i-th observation. Write some annotated R code to calculate the deletion residuals when the linear model $y_i = B_0 + B_1 X_i + B_2X_i^2 + E_i$
is fitted to the data in the file quadratic.txt. By drawing suitable plot, comment on the distribution of these deletion residuals.
Edit
I wrote some r codes , but it just gives me residual. I want to calculate deletion residual for i-th cases.
> quad<-read.table("quadratic.txt", header=T)
> quad
tha data is like this
x=(0.75078002, 0.70959645 ,0.07482854,0.60755927 ,0.55037327 ,0.55037327,
0.35458257 ,0.21994714,0.66369585,0.12381099, 0.12381099,0.12381099,
0.77869635,0.63917962)
and
y=(18.715191,17.394049,-2.346149,5.528978,6.765831,6.324425,13.803874,
15.007047,4.034973,12.383765,14.823395)
> quad.lm<-lm(y~x+I(x^2), data=quad)
> resid(quad.lm)
1 2 3 4 5 6 7
3.7933593 3.2646946 -4.9080046 -6.6589585 -4.3477835 -1.1856694 8.7046506
8 9 10 11
1.7549092 0.6237708 -3.0781575 2.0371889