Studentized residuals undefined I am wondering if anyone could explain why there are some states where Studentized residuals are undefined.
For example I got the following R code:
y <- c(0, 0, 0, 0, 0, 1) 
x <- 1:6
xx <- (1:6 - 3.5)^2
> rstudent(lm(y ~ x))
     1          2          3          4          5          6 
0.7559289  0.1428571 -0.2672612 -0.7142857 -1.5118579      NaN 

rstudent(lm(y ~ xx))
        1             2             3             4             5 
-3.008915e+00 -2.834734e-01  2.123977e-01  2.123977e-01 -2.834734e-01 
        6 
1.203157e+08 

As you can see the residual for point "6" is NaN and therefore undefined.
Plotting data I get the following plots:
plot(x,y):

plot(xx,y):
I can't figure out by myself why the residuals should not be defined in the case of lm(y ~ x).
 A: Read ?rstudent. The error variance estimate used in the calculation of each Studentized residual is got by re-fitting the model on all the other observations. (These are often called deletion residuals, or externally Studentized residuals.) So what estimate of error variance do you get when excluding the sixth observation in this example?
[Raw residuals can be standardized by dividing each by an estimate of its standard deviation
$$s_i = \frac{e_i}{\hat\sigma \sqrt{1-h_{ii}}}$$
where $\hat\sigma$ is the estimate of residual standard error, & $h_{ii}$  the $i$th diagonal element of the hat matrix. If you want to detect outliers, then, reasoning that the estimate of residual standard error will be too high if the $i$th observation is indeed an outlier, you can use deletion residuals: 
$$s_{-i} = \frac{e_i}{\hat\sigma_{-i} \sqrt{1-h_{ii}}}$$
where $\hat\sigma_{-i}$ is the estimate of residual standard error got by fitting the model on all observations except the $i$th.
As the first five observations of the response are identical, $\hat\sigma_{-6}$=0. So you're seeing NaN or $1.2\times10^8$ for the sixth deletion residual because you're dividing by zero, but this is just an extreme case of deletion residuals doing their job. It wouldn't arise in practice because you wouldn't be treating this kind of response as a continuous variable.]
