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()
# 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 using lv_correlations()
lvcors <- lv_correlations(mod)
names(lvcors)
lapply(lvcors, class)
# The above works, but it is now recommended to use the more
# flexible and informative residual_cor() function to
# calculate and work with these correlations
lvcors <- residual_cor(mod)
names(lvcors)
lvcors$cor
# For those correlations whose credible intervals did not include
# zero, plot them as a correlation matrix (all other correlations
# are shown as zero on this plot)
plot(lvcors, cluster = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.