quantileResiduals | R Documentation |
Produces quantile residuals for objects of class DDPstar
as produced by function DDPstar
.
## S3 method for class 'DDPstar'
quantileResiduals(object, parallel = c("no", "multicore", "snow"),
ncpus = 1, cl = NULL, ...)
object |
An object of class |
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 |
... |
further arguments passed to or from other methods. Not yet implemented |
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.
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 |
Dunn, P. K. and Smyth, G. K. (1996). Randomized Quantile Residuals. Journal of Computational and Graphical Statistics, 5(3), 236-244.
DDPstar
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.