residuals-methods | R Documentation |
Residuals of models fitted with functions betabin
and negbin
(formal class “glimML”), or
quasibin
and quasipois
(formal class “glimQL”).
## S4 method for signature 'glimML'
residuals(object, type = c("pearson", "response"), ...)
## S4 method for signature 'glimQL'
residuals(object, type = c("pearson", "response"), ...)
object |
Fitted model of formal class “glimML” or “glimQL”. |
type |
Character string for the type of residual: “pearson” (default) or “response”. |
... |
Further arguments to be passed to the function, such as |
For models fitted with betabin
or quasibin
, Pearson's residuals are computed as:
\frac{y - n * \hat{p}}{\sqrt{n * \hat{p} * (1 - \hat{p}) * (1 + (n - 1) * \hat{\phi})}}
where y
and n
are respectively the numerator and the denominator of the response, \hat{p}
is the fitted probability and \hat{\phi}
is the fitted overdispersion parameter. When n = 0
, the
residual is set to 0. Response residuals are computed as y/n - \hat{p}
.
For models fitted with negbin
or quasipois
, Pearson's residuals are computed as:
\frac{y - \hat{y}}{\sqrt{\hat{y} + \hat{\phi} * \hat{y}^2}}
where y
and \hat{y}
are the observed and fitted counts, respectively. Response residuals are
computed as y - \hat{y}
.
A numeric vector of residuals.
Matthieu Lesnoff matthieu.lesnoff@cirad.fr, Renaud Lancelot renaud.lancelot@cirad.fr
residuals.glm
data(orob2)
fm <- betabin(cbind(y, n - y) ~ seed, ~ 1,
link = "logit", data = orob2)
#Pearson's chi-squared goodness-of-fit statistic
sum(residuals(fm, type = "pearson")^2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.