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
use Array1;
use Family;
use GlmFit;
/// Pearson residuals `(yᵢ − μᵢ) / √V(μᵢ)`.
///
/// The raw residual scaled by the family's standard deviation (the `√φ` factor
/// is left out, matching R). Their sum of squares is the Pearson χ² statistic,
/// which — divided by `n − p` — is exactly the dispersion estimate the Gamma fit
/// reports. Pearson residuals are simple but skewed for the count families; for
/// a more symmetric scale prefer [`deviance_residuals`].
/// Deviance residuals `sign(yᵢ − μᵢ) · √d(yᵢ, μᵢ)`.
///
/// The signed square root of each observation's unit deviance; their sum of
/// squares **is** the residual deviance. Deviance residuals are the more
/// symmetric, better-behaved scale for spotting poorly-fit points in a GLM,
/// which is why they are the default for GLM residual plots.