Description Usage Arguments Details Value See Also Examples
View source: R/variance_plots.R
This function calls the boral function calc.varpart
to
estimate the proportion of variance accounted for by explanatory variables,
latent variables and any row effects. It returns the results as a data frame
suitable for plotting with ggplot. It is used by gg_varpart
but
you can also use it directly if you are constructing plots 'manually'.
1 | gg_varpart_data(model)
|
model |
A boral model fitted with one or more latent variables. |
This function requires that you fitted the model with explanatory variables
and specified save.model = TRUE
when calling boral so that MCMC samples
were stored.
A data frame to use with ggplot that has the following columns:
Variance component: one of X (explanatory variables), lv (latent variables), row (row effects).
Estimated proportion of variance.
Name of the response (e.g. species).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #' library(boral)
library(ggboral)
data(spider, package = "mvabund")
y <- spider$abun
X <- scale(spider$x)
# Warning - these settings are only to make the example run quickly.
# Don't use them for a real analysis!
example.control <- list(n.burnin = 10, n.iteration = 100, n.thin = 1)
# Note that we specify save.model = TRUE when calling boral
#
spiderfit_nb <- boral(y, X,
family = "negative.binomial",
lv.control = list(num.lv = 2),
row.eff = "fixed",
mcmc.control = example.control,
save.model = TRUE)
dat.varpart <- gg_varpart_data(spiderfit_nb)
head(dat.varpart)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.