Description Usage Arguments Value Note See Also Examples
This is a ggplot version of the boral function lvsplot
to draw an ordination-style graph of latent variables (sites or objects)
and their corresponding coefficients (species or attributes).
1 2 3 4 5 6 | gg_lvsplot(
model,
scaling = 1,
lvs = c(1, 2),
include = c("both", "objects", "attributes")
)
|
model |
A boral model fitted with one or more latent variables. |
scaling |
A numeric value between 0.8 and 1.2 that controls the relative scaling of latent variables (e.g. sites) and latent variable coefficients (e.g. species). |
lvs |
Integer indices of the latent variables to plot. |
include |
One of the following: |
A ggplot object for the latent variable graph.
Presently this function only graphs two latent variables.
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 29 30 31 32 33 34 35 | # This example is based on that for the lvsplot function
# in the boral package and requires an example dataset from the
# mvabund package.
library(boral)
library(ggboral)
data(spider, package = "mvabund")
y <- spider$abun
# 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)
spiderfit_nb <- boral(y, family = "negative.binomial",
lv.control = list(num.lv = 2),
row.eff = "fixed",
mcmc.control = example.control)
gg_lvsplot(spiderfit_nb)
# Since the function returns a ggplot object you can tweak it further.
# Here we add labels and a white background.
last_plot() +
labs(x = "Latent variable 1", y = "Latent variable 2",
title = "Example unconstrained model of spider abundance") +
theme_bw()
# Only display sites (objects) and not species (attributes)
#
gg_lvsplot(spiderfit_nb, include = "obj") +
labs(x = "Latent variable 1", y = "Latent variable 2",
title = "Site relationships from unconstrained model") +
theme_bw()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.