residuals.gamlss {gamlss} | R Documentation |
Extract Residuals from GAMLSS model
Description
residuals.gamlss
is the GAMLSS specific method for the generic function residuals
which extracts the
residuals for a fitted model. The abbreviated form resid
is an alias for residuals
.
Usage
## S3 method for class 'gamlss'
residuals(object, what = c("z-scores", "mu", "sigma", "nu", "tau"),
type = c("simple", "weighted", "partial"),
terms=NULL, ...)
Arguments
object |
a GAMLSS fitted model |
what |
specify whether the standardized residuals are required, called here the "z-scores", or residuals for a specific parameter |
type |
the type of residual if residuals for a parameter are required |
terms |
if type is "partial" this specifies which term is required |
... |
for extra arguments |
Details
The "z-scores" residuals saved in a GAMLSS object are the normalized (randomized) quantile residuals (see Dunn and Smyth, 1996).
Randomization is only needed for the discrete family distributions, see also rqres.plot
. Residuals for a specific parameter can be
"simple" = (working variable - linear predictor), "weighted"= sqrt(working weights)*(working variable - linear predictor) or
"partial"= (working variable - linear predictor)+contribution of specific terms.
Value
a vector or a matrix of the appropriate residuals of a GAMLSS model. Note that when weights are used in the fitting the length of the residuals can be
different from N
the length of the fitted values. Observations with weights equal to zero are not appearing in the residuals.
Also observations with frequencies as weights will appear more than once according to their frequencies.
Note
The "weighted" residuals of a specified parameter can be zero and one if the square of first derivative have been used in the fitting of this parameter
Author(s)
Mikis Stasinopoulos and Bob Rigby
References
Rigby, R. A. and Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion), Appl. Statist., 54, part 3, pp 507-554.
Rigby, R. A., Stasinopoulos, D. M., Heller, G. Z., and De Bastiani, F. (2019) Distributions for modeling location, scale, and shape: Using GAMLSS in R, Chapman and Hall/CRC. An older version can be found in https://www.gamlss.com/.
Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R. Journal of Statistical Software, Vol. 23, Issue 7, Dec 2007, https://www.jstatsoft.org/v23/i07/.
Stasinopoulos D. M., Rigby R.A., Heller G., Voudouris V., and De Bastiani F., (2017) Flexible Regression and Smoothing: Using GAMLSS in R, Chapman and Hall/CRC.
(see also https://www.gamlss.com/).
See Also
print.gamlss
, summary.gamlss
, fitted.gamlss
, coef.gamlss
,
residuals.gamlss
, update.gamlss
, plot.gamlss
, deviance.gamlss
, formula.gamlss
Examples
data(aids)
h<-gamlss(y~poly(x,3)+qrt, family=NBI, data=aids) #
plot(aids$x,resid(h))
plot(aids$x,resid(h,"sigma") )
rm(h)