tests/testthat/test-commutation_mat.R

test_that("commutation matrix n = 2", {
   C <- commutation_mat(2)

   m <- matrix(c(1, 0, 0, 0,
                 0, 0, 1, 0,
                 0, 1, 0, 0,
                 0, 0, 0, 1), ncol = 4, byrow = TRUE)

   expect_equal(C, m)
})

test_that("commutation matrix n = 3", {
  C <- commutation_mat(3)

  m <- matrix(c(1, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 1, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 1, 0, 0,
                0, 1, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 1, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 1, 0,
                0, 0, 1, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 1, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 1), ncol = 9, byrow = TRUE)

  expect_equal(C, m)
})

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.