Learn R Programming

boral (version 0.4)

fitted.boral: Extract Model Fitted Values for an boral object

Description

Calculated the predicted mean responses based on the fitted boral model, by using the posterior medians or means of the parameters.

Usage

## S3 method for class 'boral':
fitted(object, est = "median",...)

Arguments

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

Value

  • A list with potential NULL elements in it, containing ordinal.probs which is an array with dimensions (no. of rows of $y$) x (no. of rows of $y$) x (no. of levels) containing the predicted probabilities for ordinal columns, and out which is a matrix of the same dimension as the original response matrix y containing the fitted values.

Details

This fitted values here are calculated based on a point estimate of the parameters, as determined by the argument est. A fully Bayesian approach would calculate the fitted values by averaging over the posterior distribution of the parameters i.e., ergodically average over the MCMC samples. For simplicity and speed though (to avoid generation of a large number of predicted values), this is not implemented.

See Also

plot.boral which uses the fitted values calculated from this function to construct plots for residual analysis; ds.residuals for calculating the Dunn-Smyth residuals for a fitted 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)

fitted(spider.fit.nb)

Run the code above in your browser using DataLab