Function to compute quantile and response residuals.

# S3 method for bamlss
residuals(object, type = c("quantile", "response"),
nsamps = NULL, ...)

# S3 method for bamlss.residuals
plot(x, which = c("hist-resid", "qq-resid", "wp"),
spar = TRUE, ...)

## Arguments

object

An object of class "bamlss".

type

The type of residuals wanted, possible types are "quantile" residuals and "response" residuals.

nsamps

If the fitted bamlss object contains samples of parameters, computing residuals may take quite some time. Therefore, to get a first feeling it can be useful to compute residuals only based on nsamps samples, i.e., nsamps specifies the number of samples which are extracted on equidistant intervals.

x

Object returned from function residuals.bamlss().

which

Should a histogram with kernel density estimates be plotted, a qq-plot or a worm plot?

spar

Should graphical parameters be set by the plotting function?

...

## Value

A vector of residuals.

## References

Dunn P. K., and Smyth G. K. (1996). Randomized Quantile Residuals. Journal of Computational and Graphical Statistics 5, 236--244.

van Buuren S., and Fredriks M. (2001) Worm Plot: Simple Diagnostic Device for Modelling Growth Reference Curves. Statistics in Medicine, 20, 1259--1277

## See also

bamlss, predict.bamlss, fitted.bamlss.

## Examples

if (FALSE) ## Generate data.
d <- GAMart()

## Estimate models.
b1 <- bamlss(num ~ s(x1), data = d)
#> Error in bamlss(num ~ s(x1), data = d): object 'd' not found
b2 <- bamlss(num ~ s(x1) + s(x2) + s(x3), data = d)
#> Error in bamlss(num ~ s(x1) + s(x2) + s(x3), data = d): object 'd' not found

## Extract quantile residuals.
e1 <- residuals(b1, type = "quantile")
#> Error in residuals(b1, type = "quantile"): object 'b1' not found
e2 <- residuals(b2, type = "quantile")
#> Error in residuals(b2, type = "quantile"): object 'b2' not found

## Plots.
plot(e1)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'e1' not found
plot(e2)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'e2' not found