Usage
## S3 method for class 'gamlss2'
residuals(object,
type = c("quantile", "response", "parameter"), newdata = NULL, ...)
## S3 method for class 'gamlss2.residuals'
plot(x, which = NULL, spar = TRUE, ...)
Details
Normalized quantile residuals are obtained by evaluating the fitted distribution function at the observed responses and transforming the resulting probabilities to the standard normal scale. For continuous response distributions this is
\(r_i = \Phi^{-1}\{F(y_i | \hat\theta_i)\},\)
where \(F()\) is the fitted cumulative distribution function and \(\hat\theta_i\) denotes the fitted distribution parameters for observation \(i\).
For discrete response distributions, randomized quantile residuals are used: a uniform random probability is drawn between the fitted distribution probabilities just below and at the observed response before applying the standard normal quantile function. Thus, repeated calls may differ for discrete families unless the random-number seed is fixed.
If the family object supplies a family-specific residual function, this is used. Otherwise, quantile residuals are computed from the family cumulative distribution function. If no cumulative distribution function is available, the function falls back to response residuals and issues a warning.
Response residuals are computed as
\(y_i - \mu(\hat\theta_i),\)
where \(\mu()\) is the family mean function if available. Otherwise the first distribution parameter is used as the fitted mean.
Non-finite residuals are replaced by NA. The plotting method provides simple residual diagnostics for checking whether quantile residuals are approximately standard normal.