fitted.boral | R Documentation |
Calculated the fitted values based on the response or linear predictor scale, by using the posterior medians or means of the parameters.
## S3 method for class 'boral'
fitted(object, est = "median", include.ranef = TRUE, linear.predictor = FALSE, ...)
object |
An object of class "boral". |
est |
A choice of either the posterior median ( |
include.ranef |
If response-specific random intercepts were included as part of the fitted model, then this determines whether the predicted random effects will be included in the fitted values. When set to |
linear.predictor |
Determines the scale on which to return the fitted values. When set to |
... |
Not used. |
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.
A list containing ordinal.probs
which is an array with dimensions (number of rows of the response matrix) x (number of columns of the response matrix) 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 containing the fitted values. For ordinal columns, the "fitted values" are defined as the level/class that had the highest fitted probability.
Francis K.C. Hui [aut, cre], Wade Blanchard [aut]
Maintainer: Francis K.C. Hui <fhui28@gmail.com>
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 model.
## 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)
testpath <- file.path(tempdir(), "jagsboralmodel.txt")
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, model.name = testpath)
fitted(spiderfit_nb)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.