Learn R Programming

boral (version 0.4)

ds.residuals: Dunn-Smyth Residuals for a boral model

Description

Calculates the Dunn-Smyth residuals for a fitted boral model or, if some of the responses are ordinal, a table of agreement between predicted and true levels.

Usage

ds.residuals(object, est = "median")

Arguments

object
An object for class "boral".
est
A choice of either the posterior median (est == "median") or posterior mean (est == "mean"), which are then treated as parameter estimates and the residuals are calculated from. Default is posterior median.

Value

  • A list with potentially NULL elements, containing agree.ordinal which is a single table of agreement for ordinal columns, and residuals which contains Dunn-Smyth residuals.

Details

Details regarding Dunn-Smyth residuals, based on the randomized quantile residuals of Dunn and Symth (1996), can be found in plot.manyglm function in the mvabund package (Wang et al., 2012) where they are implemented in all their glory. Due their inherent stochasticity, Dunn-Smyth residuls will be slightly different each time this function is run. As with other types of residuals, Dunn-Smyth residuals can be used in the context of residual analysis.

For ordinal responses, a single table of agreement between the predicted levels (as based on the class with the highest probability) and true levels is returned. The table pools the results over all columns assumed to be ordinal.

The Dunn-Smyth residuals are calculated based on a point estimate of the parameters, as determined by the argument est. A fully Bayesian approach would calculate the residuals by averaging over the posterior distribution of the parameters i.e., ergodically average over the MCMC samples. In general however, the results (as in the trends seen in residual analysis) from either approach should be very similar.

References

  • Dunn, P. K., & Smyth, G. K. (1996). Randomized quantile residuals. Journal of Computational and Graphical Statistics, 5, 236-244.
  • Wang, Y., Naumann, U., Wright, S. T., & Warton, D. I. (2012). mvabund-an R package for model-based analysis of multivariate abundance data. Methods in Ecology and Evolution, 3, 471-474.

See Also

plot.boral for constructing residual analysis plots directly; fitted.boral which calculated fitted values from a boral model.

Examples

Run this code
library(mvabund) ## Load a dataset from the mvabund package
data(spider)
y <- spider$abun

spider.fit.nb <- boral(y, family = "negative.binomial", num.lv = 2, 
     site.eff = TRUE, n.burnin = 10, n.iteration = 100, 
     n.thin = 1, calc.ics = FALSE)

ds.residuals(spider.fit.nb)

Run the code above in your browser using DataLab