13 Scenario XII: Using further constraints
13.1 General assumptions
adoptr
offers the possibility to use a variety of further constraints. This chapter is dedicated to show a first scenario in which further conditions on the trial need to be met. We assume a classical two-arm trial with normal test statistic and known variance. The null hypothesis is given by \(\mathcal{H}_0: \delta \leq 0\) and the alternative is assumed to be an effect size of \(\delta=0.5\) with point prior distribution. The type one error rate should be lower than \(\alpha=0.025\) and the power at the alternative must be at least \(0.9\). The objective function to be minimized is the expected sample size under the alternative, i.e. \(\boldsymbol{E}\big[n(\mathcal{D})\big]\).
<- Normal(two_armed = TRUE)
datadist <- PointMassPrior(.0, 1)
H_0 <- PointMassPrior(0.5, 1)
prior
<- 0.025
alpha <- 0.9
min_power <- Power(datadist, H_0) <= alpha
toer_cnstr <- Power(datadist, prior) >= min_power
pow_cnstr
<- ExpectedSampleSize(datadist, prior) ess
13.2 Constraint X-1: Maximal Sample Size
13.2.1 Details
Even though the expected sample size of adaptive two-stage designs is generally lower than the expected sample size of classical one-stage designs, it is possible that the sample size of two-stage designs exceeds the sample size of one-stage designs in some cases. Thus, it is not absurd to assume that the maximum sample size should have an upper bound. We say this upper bound is given by \(120\).
<- MaximumSampleSize() <= 120 smplsize_cnstr
13.2.2 Initial Designs
As an initial design, we choose the adoptr
-function get_initial_design()
.
<- get_initial_design(0.5, alpha, 1 - min_power, type_design = "two-stage",
init_twostage dist = datadist)
13.2.3 Optimization
<- minimize(ess, subject_to(toer_cnstr, pow_cnstr, smplsize_cnstr),
opt_twostage_cnstr initial_design = init_twostage)
13.2.4 Testcases
At first, we verify the type one error rate and power constraints by simulation:
<- sim_pr_reject(opt_twostage_cnstr$design, 0.0, datadist)
toer <- sim_pr_reject(opt_twostage_cnstr$design, 0.5, datadist)
power
::expect_true(toer$prob <= alpha * (1 + tol))
testthat::expect_true(power$prob >= min_power * (1 - tol)) testthat
We now check that the maximal sample size is always smaller than \(118\):
::expect_true(evaluate(MaximumSampleSize(), opt_twostage_cnstr$design) <= 120) testthat
Since we added a constraint to our minimization problem, the expected sample size of this design should be higher than the expected sample size without the constraint on the maximum sample size.
<- minimize(ess,subject_to(toer_cnstr,pow_cnstr),initial_design = init_twostage)
opt_twostage
::expect_true(evaluate(ess,opt_twostage_cnstr$design)>= evaluate(ess,opt_twostage$design)) testthat