qresiduals.Rd
Generic function and methods for computing (randomized) quantile residuals.
qresiduals(object, ...)
# S3 method for default
qresiduals(object, scale = "normal", ...)
an object. For the default
method this needs to be
either a specification of probabilities (vector or 2-dimensional matrix of
probabilities) or an object from which the these can be obtained with
procast
.
further parameters passed to pitresiduals
.
On which scale should the PIT residuals be shown; on the probability scale
("uniform"
) or on the normal scale ("normal"
).
Here, for (randomized) quantile residuals, the
quantiles of the standard normal distribution are computed per default.
A vector or matrix of quantile residuals.
(Randomized) quantile residuals are simply the theoretical standard normal quantiles evaluated at the PIT residuals as suggested by Dunn and Smyth (1996). For regression models with a continuous response distribution these are exact; for discrete distributions, PIT residuals are drawn from the range of probabilities corresponding to each observation, hence quantile residuals must be random as well.
The default qresiduals
method calls pitresiduals
with
scale
equal "normal"
, as employed in normal Q-Q
plots (qqrplot
).
Note that there is also a qresiduals
function
in the statmod package that is not generic and always returns a single
random quantile residual.
Dunn KP, Smyth GK (1996). “Randomized Quantile Residuals.” Journal of Computational and Graphical Statistics, 5(3), 236--244. doi:10.2307/1390802
## linear regression models (homoscedastic Gaussian response)
m <- lm(dist ~ speed, data = cars)
qresiduals(m)
#> 1 2 3 4 5 6
#> 0.25545799 0.78635431 -0.39470591 0.79981078 0.14067589 -0.51845901
#> 7 8 9 10 11 12
#> -0.24852535 0.28237096 0.81326725 -0.57585005 0.15413237 -1.03589883
#> 13 14 15 16 17 18
#> -0.63772660 -0.37227844 -0.10683030 -0.50051704 0.03037928 0.03037928
#> 19 20 21 22 23 24
#> 0.82672373 -0.76147969 -0.09785931 1.49482961 2.82207038 -1.42061458
#> 25 26 27 28 29 30
#> -1.02244235 0.83569472 -0.88523278 -0.35433648 -1.14619544 -0.61529914
#> 31 32 33 34 35 36
#> 0.04832124 -0.74353772 0.18553081 1.51277158 2.04366789 -1.40267261
#> 37 38 39 40 41 42
#> -0.73905224 0.72091261 -1.92908343 -0.86729081 -0.60184266 -0.33639451
#> 43 44 45 46 47 48
#> 0.19450179 -0.19469944 -1.25200657 -0.45117662 1.00878823 1.07515027
#> 49 50
#> 2.86692531 0.28329130