tests/testthat/test_update_alpha_beta.R

context("Update Alpha Beta HMM")

test_that("Log Posterior", {

  expect_is(alphabeta_log_posterior(2, 2, rep(1, 10)),
            "numeric")


  ### This gives warning, need to account for negatives
  expect_is(alphabeta_log_posterior(2, -2, rep(1, 10)),
            "numeric")
  expect_equal(alphabeta_log_posterior(2, -2, rep(1, 10)), -Inf)
  expect_equal(alphabeta_log_posterior(-2, 2, rep(1, 10)), -Inf)
  expect_equal(alphabeta_log_posterior(-2, -2, rep(1, 10)), -Inf)

})

test_that("MH Sampling", {

  newPars <- update_alpha_beta(rep(1, 10))

  expect_length(newPars, 2)
  expect_is(newPars, "numeric")

})

Try the dirichletprocess package in your browser

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

dirichletprocess documentation built on Aug. 25, 2023, 5:19 p.m.