Extract residuals
Details
For Pearson residuals the variance formula depends on the
reparameterization stored in object$repar:
- repar = 1 (precision)
V = mu(1 - mu) / (1 + phi)
- repar = 2 (mean-variance)
V = mu(1 - mu) * phi
The weighted and sweighted residuals use the digamma/trigamma
formulation from the precision parameterization (repar = 1),
so internal conversion is applied when repar != 1.
Examples
# \donttest{
dat <- data.frame(
y = c(
0, 5, 20, 50, 75, 90, 100, 30, 60, 45,
10, 40, 55, 70, 85, 25, 35, 65, 80, 15
),
x1 = rep(c(1, 2), 10)
)
prep <- brs_prep(dat, ncuts = 100)
#> brs_prep: n = 20 | exact = 0, left = 1, right = 1, interval = 18
fit <- brs(y ~ x1, data = prep)
head(residuals(fit))
#> [1] -0.50871261 -0.40380411 -0.30872261 0.04619589 0.24127739 0.44619589
head(residuals(fit, type = "pearson"))
#> 1 2 3 4 5 6
#> -1.6029039 -1.2776185 -0.9727549 0.1461618 0.7602416 1.4117443
# }
