1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use Array1;
use crateOlsFit;
/// Internally studentized residuals `rᵢ = eᵢ / (s·√(1 − hᵢ))`.
///
/// Each raw residual is scaled by its own standard deviation, which shrinks
/// toward zero as leverage `hᵢ` grows. "Internally" means the global residual
/// standard error `s` (which was itself computed *using* observation `i`) is
/// used. This is R's `rstandard`.
/// Externally studentized residuals `tᵢ = eᵢ / (s₍ᵢ₎·√(1 − hᵢ))`.
///
/// "Externally" means observation `i` is *excluded* from the variance estimate
/// used to scale its own residual:
///
/// `s₍ᵢ₎² = [(n − p)·s² − eᵢ²/(1 − hᵢ)] / (n − p − 1)`
///
/// so a genuine outlier no longer inflates the very scale it is judged against —
/// which is why this form (R's `rstudent`) is the one that follows a Student-t
/// distribution and underlies DFFITS. Requires `n − p − 1 ≥ 1`; entries are
/// `NaN` otherwise.