Learn R Programming

boral (version 0.4)

plot.boral: Plots of a fitted boral object

Description

Produces four plots relating to the fitted boral object, which can be used for residual analysis.

Usage

## S3 method for class 'boral':
plot(x, est = "median", jitter = FALSE, a = 1,...)

Arguments

x
An object of class "boral".
est
A choice of either the posterior median (est == "median") or posterior mean (est == "mean") of the parameters, which are then treated as parameter estimates and the fitted values/residuals used in the plots are calculated from. D
jitter
If jitter = TRUE, then some jittering is applied so that points on the plots do not overlap exactly (which can often occur with discrete data). Please see jitter for its implementation.
a
Default parameter used in cex. Graphical options are then adjusted as par(ask = T, cex = a, cex.main = a, ...). Defaults to 1.
...
Additional graphical options to be included in par.

Details

Four types of plots are provided:
  1. Plot of Dunn-Smyth residuals against the linear predictors. This can be useful to assess whether the mean variance assumption as been adequately satisfied, as well as to look for particular outliers.
  2. Plot of Dunn-Smyth residuals against the row index/row names.
  3. Plot of Dunn-Smyth residuals against the column index/column names. Both this and the previous plot are useful for assessing how well each row/column of the response matrix is being modelled.
  4. A normal quantile plot of the Dunn-Smyth residuals, which can be used to assess the normality assumption and overall goodness of fit.

See Also

fitted.boral to obtain the fitted values, ds.residuals to obtain Dunn-Smyth residuals and details as to what they are.

Examples

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

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

plot(spider.fit.p, which = 1:4) 
## A distinct fan pattern is observed in the plot of Dunn-Smyth residuals 
## versus linear predictors plot. 
## The normal quantile plot also suggests some lack of fit.

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

plot(spider.fit.nb, which = 1:4) 
## The fan shape is not as clear now, 
## and the normal quantile plot also suggests a better fit to the data

Run the code above in your browser using DataLab