tests/testthat/test-bvhar-minnesota.R

# Components of var-type--------------
test_that("Test for VAR-type minnesota", {
  skip_on_cran()
  
  etf_ncol <- ncol(etf_vix)
  var_spec <- set_bvhar(
    sigma = apply(etf_vix, 2, sd),
    lambda = .2,
    delta = rep(.1, etf_ncol)
  )
  fit_test_bvhar_var <- bvhar_minnesota(
    y = etf_vix,
    bayes_spec = var_spec
  )
  
  expect_s3_class(var_spec, "bvharspec")
  expect_s3_class(fit_test_bvhar_var, "bvharmn")
  
  expect_equal(
    nrow(fit_test_bvhar_var$coef), 
    ncol(etf_vix) * 3 + 1
  )
  expect_equal(
    ncol(fit_test_bvhar_var$coef),
    ncol(etf_vix)
  )
  
})
# Components of vhar-type--------------
test_that("Test for VHAR-type minnesota", {
  skip_on_cran()
  
  etf_ncol <- ncol(etf_vix)
  vhar_spec <- set_weight_bvhar(
    sigma = apply(etf_vix, 2, sd),
    lambda = .2,
    daily = rep(.3, etf_ncol),
    weekly = rep(.2, etf_ncol),
    monthly = rep(.1, etf_ncol)
  )
  fit_test_bvhar_vhar <- bvhar_minnesota(
    y = etf_vix,
    num_iter = 10,
    num_burn = 0,
    bayes_spec = vhar_spec
  )
  
  expect_s3_class(vhar_spec, "bvharspec")
  expect_s3_class(fit_test_bvhar_vhar, "bvharmn")
  
  expect_equal(
    nrow(fit_test_bvhar_vhar$coef), 
    ncol(etf_vix) * 3 + 1
  )
  expect_equal(
    ncol(fit_test_bvhar_vhar$coef),
    ncol(etf_vix)
  )
  
})
#> Test passed 🌈

Try the bvhar package in your browser

Any scripts or data that you put into this service are public.

bvhar documentation built on April 4, 2025, 5:22 a.m.