tests/testthat/test-monotonicity.R

test_that("within-trial monotonicity conditions coincide with published results
           (see Tab. 2, Baumann et al. 2022)",
          {
  # Baumann, L., Krisam, J., & Kieser, M. (2022). Monotonicity conditions for
  # avoiding counterintuitive decisions in basket trials. Biometrical Journal,
  # 64(5), 934-947.
  design3 <- setup_fujikawa_x(k = 3,
                              shape1 = 1,
                              shape2 = 1,
                              p0 = 0.2)
  design4 <- setup_fujikawa_x(k = 4,
                             shape1 = 1,
                             shape2 = 1,
                             p0 = 0.2)
  expect_equal(check_mon_within(design = design3, n = 24,
                                 lambda = 0.99,
                                 weight_fun = baskexact::weights_fujikawa,
                                 weight_params = list(epsilon = 5,
                                                      tau = 0.4,
                                                      logbase = 2),
                                details = FALSE),
               TRUE)
  expect_equal(check_mon_within(design = design4, n = 24,
                                lambda = 0.99,
                                weight_fun = weights_jsd,
                                weight_params = list(epsilon = 7,
                                                     tau = 0.3,
                                                     logbase = 2),
                                details = FALSE),
               FALSE)
})

test_that("between-trial monotonicity conditions coincide with published results
           (see Tab. 2, Baumann et al. 2022)",
          {
    # Baumann, L., Krisam, J., & Kieser, M. (2022). Monotonicity conditions for
    # avoiding counterintuitive decisions in basket trials. Biometrical Journal,
    # 64(5), 934-947.
    design3 <- setup_fujikawa_x(k = 3,
                                shape1 = 1,
                                shape2 = 1,
                                p0 = 0.2)
    design4 <- setup_fujikawa_x(k = 4,
                                shape1 = 1,
                                shape2 = 1,
                                p0 = 0.2)
    expect_equal(check_mon_between(design = design3, n = 24,
                                  lambda = 0.99,
                                  weight_fun = baskexact::weights_fujikawa,
                                  weight_params = list(epsilon = 3,
                                                       tau = 0.1,
                                                       logbase = 2),
                                  details = FALSE),
                 FALSE)
    expect_equal(check_mon_between(design = design4, n = 24,
                                  lambda = 0.99,
                                  weight_fun = weights_jsd,
                                  weight_params = list(epsilon = 7,
                                                       tau = 0.4,
                                                       logbase = 2),
                                  details = FALSE),
                 TRUE)
          })

Try the baskwrap package in your browser

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

baskwrap documentation built on March 19, 2026, 5:09 p.m.