tests/testthat/test-bct.R

# Tests for the Box-Cox t distribution

test_that("bct passes standard distribution checks (mu=5, sigma=0.1, nu=1, tau=5)", {
  check_continuous_dist(
    dfun  = dbct,
    pfun  = pbct,
    qfun  = qbct,
    xs    = c(4.0, 4.6, 5.0, 5.4, 6.0),
    lower = 0, upper = Inf,
    mu = 5, sigma = 0.1, nu = 1, tau = 5
  )
})

test_that("bct passes standard distribution checks (mu=5, sigma=0.3, nu=2, tau=10)", {
  check_continuous_dist(
    dfun  = dbct,
    pfun  = pbct,
    qfun  = qbct,
    xs    = c(1.5, 3.0, 5.0, 7.5, 11.0),
    lower = 0, upper = Inf,
    mu = 5, sigma = 0.3, nu = 2, tau = 10
  )
})

test_that("bct AD gradient has no NaN", {
  check_ad_gradient(dbct,       rbct,       mu = 5, sigma = 0.3, nu = 2, tau = 10)
})

test_that("qbct honours lower.tail and log.p", {
  p <- c(0.01, 0.1, 0.5, 0.9, 0.99)
  args <- list(mu = 5, sigma = 0.3, nu = 2, tau = 10)
  expect_equal(do.call(qbct, c(list(p), args)),
               do.call(qbct, c(list(1 - p), args, lower.tail = FALSE)))
  expect_equal(do.call(qbct, c(list(p), args)),
               do.call(qbct, c(list(log(p)), args, log.p = TRUE)))
})

Try the RTMBdist package in your browser

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

RTMBdist documentation built on Oct. 31, 2026, 5:07 p.m.