Description Usage Arguments Details Note Author(s) See Also Examples
Produces four plots relating to the fitted boral object, which can be used for residual analysis. If some of the columns are ordinal, then a single confusion matrix is also produced.
1 2 |
x |
An object of class "boral". |
est |
A choice of either the posterior median ( |
jitter |
If |
... |
Additional graphical options to be included in. These include values for |
Four plots are provided:
Plot of Dunn-Smyth residuals against the linear predictors. This can be useful to assess whether the assumed mean-variance relationship is adequately satisfied, as well as to look for particular outliers. For ordinal responses things are more ambiguous due to the lack of single definition for "linear predictor". Therefore, instead of linear predictors the Dunn-Smyth residuals are plotted against the fitted values (defined as the level with the highest fitted probability). It is fully acknowledged that this makes things VERY hard to interpret if only some of your columns are ordinal.
Plot of Dunn-Smyth residuals against the row index/row names.
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 modeled.
A normal quantile plot of the Dunn-Smyth residuals, which can be used to assess the normality assumption and overall goodness of fit.
For ordinal responses, a single confusion matrix between the predicted levels (as based on the class with the highest probability) and true levels is aso returned. The table pools the results over all columns assumed to be ordinal.
Due the inherent stochasticity, Dunn-Smyth residuals and consequently the plots will be slightly different time this function is run. Note also the fitted values and residuals are calculated from point estimates of the parameters, as opposed to a fully Bayesian approach (please see details in fitted.boral
and ds.residuals
). Consequently, it is recommended that this function is run several times to ensure that any trends observed in the plots are consistent throughout the runs.
As mentioned above, for ordinal responses things are much more challenging as there is no single definition for "linear predictor". Instead of linear predictors then, for the first plot the Dunn-Smyth residuals are plotted against the fitted values, defined as the level with the highest fitted probability. It is fully acknowledged that this makes things VERY hard to interpret if only some of your columns are ordinal though. Suggestions to improve this are welcome!!!
NA
Maintainer: NA
fitted.boral
to obtain the fitted values, ds.residuals
to obtain Dunn-Smyth residuals and details as to what they are.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ## Not run:
## NOTE: The values below MUST NOT be used in a real application;
## they are only used here to make the examples run quick!!!
example_mcmc_control <- list(n.burnin = 10, n.iteration = 100,
n.thin = 1)
library(mvabund) ## Load a dataset from the mvabund package
data(spider)
y <- spider$abun
spider.fit.p <- boral(y, family = "poisson", lv.control = list(num.lv = 2),
row.eff = "fixed", mcmc.control = example_mcmc_control)
par(mfrow = c(2,2))
plot(spider.fit.p)
## A distinct fan pattern is observed in the plot of residuals
## versus linear predictors plot.
spiderfit_nb <- boral(y, family = "negative.binomial", lv.control = list(num.lv = 2),
row.eff = "fixed", mcmc.control = example_mcmc_control)
par(mfrow = c(2,2))
plot(spiderfit_nb)
## The fan shape is not as clear now,
## and the normal quantile plot also suggests a better fit to the data
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.