Shrinkage Priors

library(bvhar)
var_idx <- c("GVZCLS", "OVXCLS", "EVZCLS", "VXFXICLS")
etf <-
  etf_vix[1:100, ] %>%
  dplyr::select(dplyr::all_of(var_idx))
# Split-------------------------------
h <- 5
etf_eval <- divide_ts(etf, h)
etf_train <- etf_eval$train
etf_test <- etf_eval$test

Stochastic Search Variable Selection (SSVS) Prior

(fit_ssvs <- bvhar_ssvs(etf_train, num_iter = 500, include_mean = FALSE, minnesota = "longrun"))
#> Call:
#> bvhar_ssvs(y = etf_train, num_iter = 500, include_mean = FALSE, 
#>     minnesota = "longrun")
#> 
#> BVHAR with SSVS Prior
#> Fitted by Gibbs sampling
#> Total number of iteration: 500
#> Number of burn-in: 250
#> ====================================================
#> 
#> Parameter Record:
#> # A draws_df: 250 iterations, 1 chains, and 112 variables
#>     phi[1]    phi[2]    phi[3]    phi[4]     phi[5]    phi[6]    phi[7]
#> 1    0.748   0.01790  -0.00374   0.02106  -0.000456   0.04807   0.06563
#> 2    0.781   0.00923  -0.00232   0.03816  -0.010998  -0.00211   0.07880
#> 3    0.913  -0.00539   0.01807   0.02018  -0.001692  -0.02208  -0.00346
#> 4    0.902   0.00744  -0.03854  -0.00351  -0.006867  -0.00886   0.05922
#> 5    0.840   0.04047  -0.02481   0.01366   0.017026   0.02911  -0.01055
#> 6    0.868   0.01580  -0.02302   0.00926   0.000999   0.00435  -0.02162
#> 7    0.879   0.00565   0.06542  -0.00299  -0.051311   0.02893   0.08144
#> 8    0.935   0.01331   0.05494  -0.01276  -0.000930   0.00466   0.06335
#> 9    0.789   0.00135   0.06510   0.03359   0.006046  -0.00691  -0.00422
#> 10   0.930  -0.00100   0.08661  -0.00681  -0.018950   0.00269   0.05719
#>        phi[8]
#> 1   -0.002071
#> 2    0.036708
#> 3    0.014261
#> 4    0.019664
#> 5    0.000975
#> 6    0.006086
#> 7    0.024824
#> 8   -0.025001
#> 9    0.021118
#> 10   0.011626
#> # ... with 240 more draws, and 104 more variables
#> # ... hidden reserved variables {'.chain', '.iteration', '.draw'}

autoplot() for the fit (bvharsp object) provides coefficients heatmap. There is type argument, and the default type = "coef" draws the heatmap.

autoplot(fit_ssvs)

type = "trace" gives MCMC trace plot.

autoplot(fit_ssvs, type = "trace", regex_pars = "psi")

Horseshoe Prior

(fit_hs <- bvhar_horseshoe(etf_train, num_iter = 1000, include_mean = FALSE, minnesota = "longrun", verbose = TRUE))
#> Call:
#> bvhar_horseshoe(y = etf_train, num_iter = 1000, include_mean = FALSE, 
#>     minnesota = "longrun", verbose = TRUE)
#> 
#> BVHAR with Horseshoe Prior
#> Fitted by blocked sampling
#> Total number of iteration: 1000
#> Number of burn-in: 500
#> ====================================================
#> 
#> # A draws_df: 500 iterations, 1 chains, and 103 variables
#>     phi[1]  phi[2]  phi[3]  phi[4]  phi[5]   phi[6]  phi[7]    phi[8]
#> 1    0.541   0.117  0.0982  0.0906   0.160  -0.0468  0.0419  -0.01556
#> 2    0.543   0.119  0.0943  0.0889   0.161  -0.0498  0.0501  -0.01447
#> 3    0.542   0.120  0.1018  0.0854   0.156  -0.0525  0.0621  -0.00964
#> 4    0.543   0.118  0.1013  0.0870   0.160  -0.0496  0.0544  -0.01080
#> 5    0.541   0.117  0.1008  0.0899   0.156  -0.0467  0.0523  -0.01410
#> 6    0.544   0.117  0.0989  0.0878   0.162  -0.0486  0.0448  -0.01283
#> 7    0.541   0.115  0.1026  0.0902   0.156  -0.0434  0.0489  -0.01431
#> 8    0.540   0.119  0.0960  0.0901   0.159  -0.0497  0.0583  -0.01429
#> 9    0.542   0.119  0.1037  0.0862   0.163  -0.0518  0.0555  -0.01213
#> 10   0.544   0.117  0.1008  0.0880   0.159  -0.0497  0.0517  -0.01319
#> # ... with 490 more draws, and 95 more variables
#> # ... hidden reserved variables {'.chain', '.iteration', '.draw'}
autoplot(fit_hs)

type = "dens" draws MCMC density plot.

autoplot(fit_hs, type = "dens", regex_pars = "tau")

Models with Stochastic Volatilities

SSVS

(fit_ssvs_sv <- bvhar_sv(etf_train, num_iter = 500, bayes_spec = set_ssvs(), include_mean = FALSE, minnesota = "longrun"))
#> Call:
#> bvhar_sv(y = etf_train, num_iter = 500, bayes_spec = set_ssvs(), 
#>     include_mean = FALSE, minnesota = "longrun")
#> 
#> BVHAR with Stochastic Volatility
#> Fitted by Gibbs sampling
#> Total number of iteration: 500
#> Number of burn-in: 250
#> ====================================================
#> 
#> Parameter Record:
#> # A draws_df: 250 iterations, 1 chains, and 66 variables
#>     phi[1]   phi[2]  phi[3]   phi[4]    phi[5]   phi[6]  phi[7]  phi[8]
#> 1    1.046  -0.0235    1.12  -0.1127  -0.17861  -0.0742  -0.665   0.278
#> 2    1.007  -0.0334    1.11  -0.1062  -0.10771  -0.0287  -0.562   0.190
#> 3    0.955  -0.0656    1.24  -0.0807  -0.07716   0.0137  -0.632   0.151
#> 4    0.912  -0.0761    1.24  -0.1004  -0.09267   0.0452  -0.674   0.217
#> 5    0.829  -0.0440    1.34  -0.1308  -0.01241   0.0574  -0.816   0.255
#> 6    0.825  -0.0857    1.48  -0.0917   0.04611   0.1063  -1.114   0.198
#> 7    0.852  -0.0650    1.32  -0.1064   0.01163   0.0480  -0.722   0.184
#> 8    0.796  -0.1315    1.18  -0.0593  -0.00508   0.0582  -0.525   0.171
#> 9    0.878  -0.1893    1.04  -0.0689   0.03847   0.1292  -0.353   0.117
#> 10   0.825  -0.1497    1.33  -0.0672   0.06112   0.1359  -0.902   0.181
#> # ... with 240 more draws, and 58 more variables
#> # ... hidden reserved variables {'.chain', '.iteration', '.draw'}
autoplot(fit_ssvs_sv)

Horseshoe

(fit_hs_sv <- bvhar_sv(etf_train, num_iter = 500, bayes_spec = set_horseshoe(), include_mean = FALSE, minnesota = "longrun"))
#> Call:
#> bvhar_sv(y = etf_train, num_iter = 500, bayes_spec = set_horseshoe(), 
#>     include_mean = FALSE, minnesota = "longrun")
#> 
#> BVHAR with Stochastic Volatility
#> Fitted by Gibbs sampling
#> Total number of iteration: 500
#> Number of burn-in: 250
#> ====================================================
#> 
#> Parameter Record:
#> # A draws_df: 250 iterations, 1 chains, and 66 variables
#>     phi[1]   phi[2]  phi[3]  phi[4]     phi[5]  phi[6]  phi[7]  phi[8]
#> 1    0.754  -0.0547    1.75  -0.217   0.018627   0.187   -1.46   0.320
#> 2    0.767  -0.0736    1.81  -0.222   0.006133   0.210   -1.55   0.347
#> 3    0.672  -0.0938    1.80  -0.187   0.075617   0.237   -1.60   0.333
#> 4    0.705  -0.0888    1.83  -0.197   0.000662   0.230   -1.63   0.363
#> 5    0.712  -0.0736    1.71  -0.187   0.015137   0.216   -1.52   0.331
#> 6    0.788  -0.1075    2.04  -0.265   0.011078   0.243   -1.77   0.385
#> 7    0.672  -0.0797    1.79  -0.197   0.091620   0.214   -1.45   0.309
#> 8    0.673  -0.0767    1.81  -0.203   0.054275   0.217   -1.46   0.330
#> 9    0.724  -0.0655    1.67  -0.180  -0.020042   0.217   -1.42   0.316
#> 10   0.715  -0.0418    1.74  -0.231   0.117485   0.153   -1.42   0.327
#> # ... with 240 more draws, and 58 more variables
#> # ... hidden reserved variables {'.chain', '.iteration', '.draw'}
autoplot(fit_hs_sv)