Calculation of studentized deleted residuals I have a problem that asks me to calculate studentized deleted residuals from the following set of residuals:

From the original dataset:

The Hat matrix, diagonal elements hii, SSE/MSE, formula for studentized residuals, and final calculation of the residuals are below: 
s

However, I cannot reproduce these results given the formula! For example, taking the square root of a negative residual in the numerator results in an imaginary number if x>0. Is there another way to calculate these residuals, or something I am I just not getting it? Thanks! 
 A: I believe this is simply a typo. The formula should be:
$$
\frac{e_i}{\sqrt{\operatorname{SSE}(1-h_{ii})-e_i^2}}
$$
or similarly:
$$
\operatorname{sign}(e_i)\left[
\frac{e_i^2}{\operatorname{SSE}(1-h_{ii})-e_i^2}
\right]^{1/2}
$$
A: The $i$-th (internally) studentized residual $r_i$ is given by
$$
r_i = \frac{e_i}{\sqrt{\mathrm{MSE}\left(1-h_{ii}\right)}},
$$
where the residual mean square $\mathrm{MSE}$ (for which a better abbreviation would be $\mathrm{MS}_{\mathrm{Res}}$) is given by $e^\top e /\left(n-p\right)$.
The $i$-th externally studentized residual $t_i$ is given by
$$
t_i = \frac{e_i}{\sqrt{S_{\left(i\right)}^2\left(1-h_{ii}\right)}},
$$
where $S_{\left(i\right)}^2$ is calculated as the usual unbiased estimator of the error variance but based on a data set with the $i$-th observation removed.
It is straightforward to show (see, e.g., Montgomery, Peck, & Vining, 2012, p. 593) that
$$
S_{\left(i\right)}^2 = \frac{\left(n-p\right)\mathrm{MSE} - e_i^2/\left(1-h_{ii}\right)}{n-p-1}.
$$
In terms of the $i$-th internally studentized residual we get
$$
\begin{align}
S_{\left(i\right)}^2 
&= \frac{\left(n-p\right)\mathrm{MSE} - r_i^2\mathrm{MSE}}{n-p-1} \\
&= \frac{\left(n-p-r_i^2\right)\mathrm{MSE}}{n-p-1},
\end{align}
$$
and hence
$$
\begin{align}
t_i 
&= \frac{e_i}{\sqrt{\frac{\left(n-p-r_i^2\right)\mathrm{MSE}}{n-p-1}\left(1-h_{ii}\right)}} \\
&= \frac{e_i}{\sqrt{\mathrm{MSE}\left(1-h_{ii}\right)}} \cdot \sqrt{\frac{n-p-1}{n-p-r_i^2}} \\
&= r_i \cdot \sqrt{\frac{n-p-1}{n-p-r_i^2}}.
\end{align}
$$

Reference
Montgomery, D. C., Peck, E. A., & Vining, G. G. (2012). Introduction to linear regression analysis (5th ed.). John Wiley & Sons.
