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
use Array1;
use LogisticFit;
/// Pearson residuals `(yᵢ − pᵢ) / √(pᵢ(1 − pᵢ))`.
///
/// The raw residual scaled by the binomial standard deviation of that
/// observation. Their sum of squares is the Pearson χ² goodness-of-fit statistic.
/// Pearson residuals are simple but skewed for probabilities near 0 or 1; for a
/// more symmetric scale prefer [`deviance_residuals`].
/// Deviance residuals
/// `sign(yᵢ − pᵢ)·√(−2[yᵢ ln pᵢ + (1 − yᵢ) ln(1 − pᵢ)])`.
///
/// The signed square-root of each observation's contribution to the model
/// 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 logistic model, which is why they are the default for GLM residual
/// plots.