quantile.residuals: Quantile residuals.

quantileResidualsR Documentation

Quantile residuals.

Description

Produces quantile residuals for objects of class DDPstar as produced by function DDPstar.

Usage

## S3 method for class 'DDPstar'
quantileResiduals(object, parallel = c("no", "multicore", "snow"), 
  ncpus = 1, cl = NULL, ...)

Arguments

object

An object of class DDPstar as produced by function DDPstar.

parallel

A characters string with the type of parallel operation: either "no" (default), "multicore" (not available on Windows) or "snow".

ncpus

An integer with the number of processes to be used in parallel operation. Defaults to 1.

cl

An object inheriting from class cluster (from the parallel package), specifying an optional parallel or snow cluster if parallel = "snow". If not supplied, a cluster on the local machine is created for the duration of the call.

...

further arguments passed to or from other methods. Not yet implemented

Details

Quantile residuals (Dunn and Smyth, 1996) are based on the well-known fact that for a continuous random variable, say Y, with CDF given by F, one has that F(Y) \sim U(0,1). As a consequence, quantile residuals defined by \hat{r}_j = \Phi^{-1}(\hat{F}(y_j)), j = 1, \ldots, n, should follow, approximately, a standard normal distribution if a correct model has been specified. A quantile-quantile (QQ) plot can then be used to determine deviations of the quantile residuals from the standard normal distribution.

Value

As a result, the function provides a list with the following components:

x

Theoretical quantiles

y

Sample quantiles: posterior mean

ymin

Sample quantiles: posterior 0.025 quantile

ymax

Sample quantiles: posterior 0.975 quantile

References

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

See Also

DDPstar

Examples

library(DDPstar)
data(dde)
dde$GAD <- dde$GAD/7 # GAD in weeks

set.seed(10) # For reproducibility
fit_dde <- DDPstar(formula = GAD ~ f(DDE, bdeg = 3, nseg = 20, pord = 2, atau = 1, btau = 0.005), 
  data = dde, mcmc = list(nburn = 20000, nsave = 15000, nskip = 1), 
  prior = list(a = 2, b = 0.5, aalpha = 2, balpha = 2, L = 20), 
  standardise = TRUE, compute.lpml = TRUE, compute.WAIC = TRUE)

qres <- quantileResiduals.DDPstar(fit_dde)

plot(qres$x, qres$y, xlab = "Theoretical Quantiles", ylab = "Sample Quantiles", 
  cex.main = 2, cex.lab = 1.5, cex.axis = 1.5)
lines(qres$x, qres$ymin, lty = 2, lwd = 2)
lines(qres$x, qres$ymax, lty = 2, lwd = 2)
abline(a = 0, b = 1, col ="red", lwd = 2) 




DDPstar documentation built on April 3, 2025, 8:46 p.m.