Skip to contents

This function uses samples of latent trends for each series from a fitted mvgam model to calculates correlations among series' trends

Usage

lv_correlations(object)

Arguments

object

list object of class mvgam

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 'C:/Users/uqnclar2/AppData/Local/Temp/RtmpotLup8/model_0f5e123adc47a9208b1c8eaa9e58906b.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 'C:/Users/uqnclar2/AppData/Local/Temp/RtmpotLup8/model-9e8c633b5a5b.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 %/%.

#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
#>                  from stan/lib/stan_math/stan/math/prim/prob/von_mises_ccdf_log.hpp:4,
#>                  from stan/lib/stan_math/stan/math/prim/prob.hpp:359,
#>                  from stan/lib/stan_math/stan/math/prim.hpp:16,
#>                  from stan/lib/stan_math/stan/math/rev.hpp:16,
#>                  from stan/lib/stan_math/stan/math.hpp:19,
#>                  from stan/src/stan/model/model_header.hpp:4,
#>                  from C:/Users/uqnclar2/AppData/Local/Temp/RtmpotLup8/model-9e8c633b5a5b.hpp:2:
#> stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp: In function 'stan::return_type_t<T_x, T_sigma, T_l> stan::math::von_mises_cdf(const T_x&, const T_mu&, const T_k&)':
#> stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp:194: note: '-Wmisleading-indentation' is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers
#>   194 |       if (cdf_n < 0.0)
#>       | 
#> stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp:194: note: adding '-flarge-source-files' will allow for more column-tracking support, at the expense of compilation time and memory
lvcors <- lv_correlations(mod)
names(lvcors)
#> [1] "mean_correlations"      "posterior_correlations"
lapply(lvcors, class)
#> $mean_correlations
#> [1] "matrix" "array" 
#> 
#> $posterior_correlations
#> [1] "list"
#> 
# }