Response residuals y - mu or Pearson residuals
(y - mu) / sqrt(V(mu)), with mu the stored fitted values and V the
variance function of the family, unscaled by the dispersion as in
stats::residuals.glm(): 1 (Gaussian), mu (Poisson),
mu + mu^2 / theta (NB2 negative binomial), mu (1 - mu) (binomial),
mu^2 (gamma) and mu (1 - mu) / (1 + phi) (beta). For random-effects
Poisson-gamma and beta-negative-binomial random-intercept fits, whose
fitted values are marginal means, V is the marginal variance implied by
the mixing distribution; where it is not finite (beta parameter a <= 2)
the Poisson variance is used. For random-slope fits V is the
conditional variance function evaluated at the marginal mean. Pearson
residuals are not defined for the ordered and Tobit families.
Value
a numeric vector, one value per row of the original data (in that
row order), NA at rows dropped for missingness.
See also
Other panglm methods:
coefplot(),
confint.panglm(),
effectcurve(),
fitted.panglm(),
fixef(),
glance.panglm(),
logLik.panglm(),
model.matrix.panglm(),
partialeffects.panordered(),
plot.panglm(),
plot.panglm_ape(),
plot.panglm_effectcurve(),
predict.panglm(),
predict.panordered(),
summary.panglm(),
tidy.panglm(),
vcov.panglm()
Examples
data(copd)
fit <- panglm(exacerbations ~ crp, data = copd,
index = c("id", "visit"), model = "pooling",
family = "poisson")
head(residuals(fit))
#> 1 2 3 4 5 6
#> -0.1661605 1.0956670 2.9187342 -1.1280102 0.9553894 -2.0858936
head(residuals(fit, type = "pearson"))
#> 1 2 3 4 5 6
#> -0.1128970 0.7939755 2.0231625 -0.7732611 0.6681517 -1.4442623