View source: R/lv_correlations.R
| lv_correlations | R Documentation |
This function uses factor loadings from a fitted dynamic factor
mvgam model to calculate temporal correlations among series' trends.
lv_correlations(object)
object |
|
Although this function will still work, it is now recommended to use
residual_cor() to obtain residual correlation information in a more
user-friendly format that allows for a deeper investigation of relationships
among the time series.
A list object containing the mean posterior correlations and
the full array of posterior correlations.
residual_cor(), plot.mvgam_residcor()
## Not run:
#--------------------------------------------------
# Fit a model that uses two AR(1) dynamic factors to model
# the temporal dynamics of the four rodent species in the portal_data
#--------------------------------------------------
mod <- mvgam(
captures ~ series,
trend_model = AR(),
use_lv = TRUE,
n_lv = 2,
data = portal_data,
chains = 2,
silent = 2
)
# Plot the two dynamic factors
plot(mod, type = 'factors')
# Calculate correlations among the series
lvcors <- lv_correlations(mod)
names(lvcors)
lapply(lvcors, class)
# Recommended: use residual_cor() instead
lvcors <- residual_cor(mod)
names(lvcors)
lvcors$cor
# Plot credible correlations as a matrix
plot(lvcors, cluster = TRUE)
# Not needed for general use; cleans up connections for automated testing
closeAllConnections()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.