View source: R/ordinate.jsdgam.R
ordinate.jsdgam | R Documentation |
Plot an ordination of latent variables and their factor loadings from
jsdgam
models
ordinate(object, ...)
## S3 method for class 'jsdgam'
ordinate(
object,
which_lvs = c(1, 2),
biplot = TRUE,
alpha = 0.5,
label_sites = TRUE,
...
)
object |
|
... |
ignored |
which_lvs |
A |
biplot |
|
alpha |
A proportional numeric scalar between |
label_sites |
|
This function constructs a two-dimensional scatterplot in ordination space. The
chosen latent variables are first re-rotated using singular value decomposition,
so that the first plotted latent variable does not have to be the first latent variable
that was estimated in the original model. Posterior median estimates of the variables
and the species' loadings on these variables are then used to construct the resulting plot.
Some attempt at de-cluttering the resulting plot is made by using geom_label_repel()
and
geom_text_repel
from the ggrepel package, but if there are many sites and/or species
then some labels may be removed automatically. Note that you can typically get
better, more readable plot layouts if you also have the ggarrow and
ggpp packages installed
An ggplot
object
Nicholas J Clark
jsdgam()
, residual_cor()
# Fit a JSDGAM to the portal_data captures
mod <- jsdgam(
formula = captures ~
# Fixed effects of NDVI and mintemp, row effect as a GP of time
ndvi_ma12:series + mintemp:series + gp(time, k = 15),
factor_formula = ~ -1,
data = portal_data,
unit = time,
species = series,
family = poisson(),
n_lv = 2,
silent = 2,
chains = 2
)
# Plot a residual ordination biplot
ordinate(
mod,
alpha = 0.7
)
# Compare to a residual correlation plot
plot(
residual_cor(mod)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.