tests/testthat/test-loglike_bekk_asymm.R

test_that("Asymmetric Log-likelihood works with 2-dimensional sample data", {
  signs <- as.matrix(c(-1,-1))
  theta <-  c(0.026486941, -0.054371863, 0.118496142, 0.199628848, -0.007720701, -0.008865618,
              0.298887218, 0.1123, 0.00023, -0.002312, 0.04553 , 0.976954018, 0.003170047, 0.019283272, 0.941393723)
  theta <- matrix(theta, nrow = 15)


  expect_equal(trunc(loglike_asymm_bekk(theta, data.matrix(StocksBonds), signs)), -7444)
})

test_that("Asymmetric Log-likelihood equals symmetric Log-likelihood with 3-dimensional sample data", {
  signs <- as.matrix(c(-1,1,-1))
  theta_asymm <-  c( 0.0010122220, -0.0002678085,  0.0001905036,  0.0008937830,  0.0003111280,  0.0003893194,
               0.2453276126,  0.0222127631, -0.0434456548, -0.0366629406,  0.2637613982, -0.0248105673,
               0.0624407934, -0.0016446789,  0.1733957064, rep(1e-14,9),  0.9651528236, -0.0060973318,  0.0155928988,
               0.0125157899,  0.9606411455,  0.0008724460, -0.0196494968, -0.0009070321,  0.9801993180)
  theta_asymm <- matrix(theta_asymm, nrow = 33)
  theta <-  c( 0.0010122220, -0.0002678085,  0.0001905036,  0.0008937830,  0.0003111280,  0.0003893194,
               0.2453276126,  0.0222127631, -0.0434456548, -0.0366629406,  0.2637613982, -0.0248105673,
               0.0624407934, -0.0016446789,  0.1733957064,  0.9651528236, -0.0060973318,  0.0155928988,
               0.0125157899,  0.9606411455,  0.0008724460, -0.0196494968, -0.0009070321,  0.9801993180)
  theta <- matrix(theta, nrow = 24)

  expect_equal(trunc(loglike_asymm_bekk(theta_asymm, GoldStocksBonds,signs)), trunc(loglike_bekk(theta, GoldStocksBonds)))
})

test_that("Asymmetric Log-likelihood works with 3-dimensional sample data", {
  signs <- as.matrix(c(1,-1,1))
  theta <-  c( 0.0010122220, -0.0002678085,  0.0001905036,  0.0008937830,  0.0003111280,  0.0003893194,
               0.2453276126,  0.0222127631, -0.0434456548, -0.0366629406,  0.2637613982, -0.0248105673,
               0.0624407934, -0.0016446789,  0.1733957064, 0.10631, 0.001, 0.0546423, 0.00321, 0.12173, -0.002321, 0.003123, -0.009312, 0.0936432,  0.9651528236, -0.0060973318,  0.0155928988,
               0.0125157899,  0.9606411455,  0.0008724460, -0.0196494968, -0.0009070321,  0.9801993180)
  theta <- matrix(theta, nrow = 33)


  expect_equal(trunc(loglike_asymm_bekk(theta, GoldStocksBonds,signs)), 75270)
})

Try the BEKKs package in your browser

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

BEKKs documentation built on April 12, 2025, 1:17 a.m.