Learn R Programming

DHARMa (version 0.4.1)

getQuantile: calculate quantiles

Description

calculates residual quantiles from a given simulation

Usage

getQuantile(simulations, observed, integerResponse, method = c("PIT",
  "traditional"))

Arguments

simulations

a matrix with simulations from a fitted model. Rows = observations, columns = replicate simulations

observed

a vector with the observed data

integerResponse

is the response integer-valued. Only has an effect for method = "traditional"

method

the quantile randomization method used. See details

Details

The function calculates residual quantiles from the simulated data. For continuous distributions, this will simply the the value of the ecdf.

For discrete data, there are two options implemented.

The current default (available since DHARMa 0.3.1) are probability integral transform (PIT-) residuals (Smith, 1985; Dunn & Smyth, 1996; see also see also Warton, et al., 2017).

Before DHARMa 0.3.1, a different randomization procedure was used, in which the a U(-0.5, 0.5) distribution was added on observations and simulations for discrete distributions. For a completely discrete distribution, the two procedures should deliver equivalent results, but the second method has the disadvantage that a) one has to know if the distribution is discrete (DHARMa tries to recognize this automatically), and b) that it leads to inefficiencies for some distributions such as the the Tweedie, which are partly continuous, partly discrete (see e.g. https://github.com/florianhartig/DHARMa/issues/168).

References

Smith, J. Q. "Diagnostic checks of non-standard time series models." Journal of Forecasting 4.3 (1985): 283-291.

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

Warton, David I., Lo<U+00EF>c Thibaut, and Yi Alice Wang. "The PIT-trap<U+2014>A <U+201C>model-free<U+201D> bootstrap procedure for inference about regression models with discrete, multivariate responses." PloS one 12.7 (2017)