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"),
spar = TRUE, ...)
An object of class "bamlss"
.
The type of residuals wanted, possible types are
"quantile"
residuals and "response"
residuals.
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.
Object returned from function residuals.bamlss()
.
Should a histogram with kernel density estimates be plotted or a qq-plot?
Should graphical parameters be set by the plotting function?
For function residuals.bamlss()
arguments passed to possible
$residuals()
functions that may be part of a bamlss.family
. For function
plot.bamlss.residuals()
arguments passed to function
hist.default
and qqnorm.default
.
A vector of residuals.
Response residuals are the raw residuals, i.e., the response data minus the fitted distributional
mean. If the bamlss.family
object contains a function $mu(par, …)
, then
raw residuals are computed with y - mu(par)
where par
is the named list of fitted
values of distributional parameters. If $mu(par, ...)
is missing, then the fitted values
of the first distributional parameter are used.
Randomized quantile residuals are based on the cumulative distribution function of the
bamlss.family
object, i.e., the $p(y, par, ...)
function.
Dunn P. K., and Smyth G. K. (1996). Randomized Quantile Residuals. Journal of Computational and Graphical Statistics 5, 236-244.
# NOT RUN {
## Generate data.
d <- GAMart()
## Estimate models.
b1 <- bamlss(num ~ s(x1), data = d)
b2 <- bamlss(num ~ s(x1) + s(x2) + s(x3), data = d)
## Extract quantile residuals.
e1 <- residuals(b1, type = "quantile")
e2 <- residuals(b2, type = "quantile")
## Plots.
plot(e1)
plot(e2)
# }
Run the code above in your browser using DataLab