qresiduals {topmodels} | R Documentation |
Generic function and methods for computing (randomized) quantile residuals.
qresiduals(object, ...) ## Default S3 method: qresiduals(object, newdata = NULL, trafo = qnorm, type = c("random", "quantile"), nsim = 1L, delta = NULL, prob = NULL, ...)
object |
an object. For the |
newdata |
optionally, a data frame in which to look for variables with which to predict. If omitted, the original observations are used. |
trafo |
function for tranforming residuals from probability scale to a different distribution scale (default: Gaussian). |
type |
character specifying whether - in the case of discrete response distributions - randomized quantile residuals or their corresponding quantiles should be computed. |
nsim |
numeric. The number of simulated randomized quantile residuals
per observation (for |
delta |
numeric. The minimal difference to compute the range of proabilities
corresponding to each observation according to get (randomized) quantile residuals.
For |
prob |
numeric. The probabilities at which quantile residuals should be
computed (for |
... |
further parameters passed to methods. |
(Randomized) quantile residuals have been suggested by Dunn and Smyth (1996).
For regression models with a continuous response distribution this simply computes
theoretical standard normal quantiles corresponding to the probability integral transform of the
fitted distribution. For discrete distributions, a random theoretical normal
quantile is drawn from the range of probabilities corresponding to each observation.
Hence, in qqrplot
the default is to use trafo = qnorm
but other
transformations can also be used, specifically using the uniform probability
scale (via trafo = NULL
or equivalently qunif
or identity
).
The default qresiduals
method can compute randomized quantile residuals
from a vector (which essentially just calls qnorm
) or
a 2-column matrix of probabilities. The latter offers to either draw "random"
samples from the distribution or compute corresponding "quantile"
s such as
the median etc.
A vector or matrix of quantile residuals.
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, 1–10.
## linear regression models (homoscedastic Gaussian response) m <- lm(dist ~ speed, data = cars) qresiduals(m)