
Calculate trend correlations based on latent factor loadings for mvgam models
Source:R/lv_correlations.R
lv_correlations.Rd
This function uses samples of latent trends for each series from a fitted mvgam model to calculates correlations among series' trends
Value
A list
object containing the mean posterior correlations
and the full array of posterior correlations
Examples
# \donttest{
simdat <- sim_mvgam()
mod <- mvgam(y ~ s(season, bs = 'cc',
k = 6),
trend_model = AR(),
use_lv = TRUE,
n_lv = 2,
data = simdat$data_train,
burnin = 300,
samples = 300,
chains = 2,
silent = 2)
#> Warning in '/tmp/RtmpBC1K15/model_4ea86485fa6394b2bd06379ea36195d8.stan', line 23, column 31: Found
#> int division:
#> n_lv * (n_lv - 1) / 2
#> Values will be rounded towards zero. If rounding is not desired you can
#> write
#> the division as
#> n_lv * (n_lv - 1) / 2.0
#> If rounding is intended please use the integer division operator %/%.
#> Warning in '/tmp/RtmpBC1K15/model-234f10d6f0bb.stan', line 23, column 33: Found
#> int division:
#> n_lv * (n_lv - 1) / 2
#> Values will be rounded towards zero. If rounding is not desired you can
#> write
#> the division as
#> n_lv * (n_lv - 1) / 2.0
#> If rounding is intended please use the integer division operator %/%.
lvcors <- lv_correlations(mod)
names(lvcors)
#> [1] "mean_correlations" "posterior_correlations"
lapply(lvcors, class)
#> $mean_correlations
#> [1] "matrix" "array"
#>
#> $posterior_correlations
#> [1] "list"
#>
# }