Learn R Programming

boral (version 1.7)

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 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 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. For ordinal columns, the "fitted values" are defined as the level/class that had the highest fitted probability.

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
# 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

spiderfit_nb <- boral(y, family = "negative.binomial", lv.control = list(num.lv = 2),
     row.eff = "fixed", mcmc.control = example_mcmc_control)

fitted(spiderfit_nb)
# }

Run the code above in your browser using DataLab