@@ -209,10 +209,50 @@ testthat::test_that("Test gsBinomialExact for n.I and vector-b for increasing or
209
209
})
210
210
211
211
212
+ # ## Test gsBinomialExact for properly increasing n.I
213
+ testthat :: test_that(" Test gsBinomialExact for properly increasing n.I" , code = {
214
+ testthat :: expect_error(gsBinomialExact(
215
+ k = 2 , theta = c(.1 , .2 ), n.I = c(50 , 50 ),
216
+ a = c(3 , 7 ), b = c(20 , 30 )
217
+ ),
218
+ info = " Checking properly increasing n.I"
219
+ )
220
+ })
221
+
222
+ # ## Test gsBinomialExact for b greater than a
223
+ testthat :: test_that(" Test gsBinomialExact for b greater than a" , code = {
224
+ testthat :: expect_error(gsBinomialExact(
225
+ k = 2 , theta = c(.1 , .2 ), n.I = c(50 , 100 ),
226
+ a = c(25 , 50 ), b = c(15 , 40 )
227
+ ),
228
+ info = " Checking for b greater than a"
229
+ )
230
+ })
231
+
232
+ # ## Test gsBinomialExact for a being a non-decreasing sequence of non-negative integers
233
+ testthat :: test_that(" Test gsBinomialExact for a being a non-decreasing sequence of non-negative integers" , code = {
234
+ testthat :: expect_error(gsBinomialExact(
235
+ k = 2 , theta = c(.1 , .2 ), n.I = c(50 , 100 ),
236
+ a = c(25 , 20 ), b = c(30 , 40 )
237
+ ),
238
+ info = " Checking a for being a non-decreasing sequence of non-negative integers"
239
+ )
240
+ })
241
+
242
+ # ## Test gsBinomialExact for n.I - b being a non-decreasing sequence
243
+ testthat :: test_that(" Test gsBinomialExact for n.I - b being a non-decreasing sequence" , code = {
244
+ testthat :: expect_error(gsBinomialExact(
245
+ k = 2 , theta = c(.1 , .2 ), n.I = c(50 , 100 ),
246
+ a = c(3 , 7 ), b = c(25 , 100 )
247
+ ),
248
+ info = " Checking for n.I - b being a non-decreasing sequence"
249
+ )
250
+ })
251
+
212
252
213
253
# Test gsBinomial Exact for upper efficacy boundary crossing probabilities: Benchmark values have been obtained from East 6.5
214
254
testthat :: test_that(
215
- desc = " Test gsBinomial Exact for upper efficacy bounday crossing probabilities :
255
+ desc = " Test gsBinomial Exact for upper efficacy boundary crossing probabilities :
216
256
Benchmark values have been obtained from East 6.5 : BinomialExact-01.html" ,
217
257
code = {
218
258
x <- gsBinomialExact(
@@ -252,9 +292,9 @@ testthat::test_that(
252
292
)
253
293
254
294
255
- # Test gsBinomial Exact for lower futility bounday crossing probabilities : Benchmark values have been obtained from East 6.5
295
+ # Test gsBinomial Exact for lower futility boundary crossing probabilities : Benchmark values have been obtained from East 6.5
256
296
testthat :: test_that(
257
- desc = " Test gsBinomial Exact for lower futility bounday crossing probabilities :
297
+ desc = " Test gsBinomial Exact for lower futility boundary crossing probabilities :
258
298
Benchmark values have been obtained from East 6.5 : BinomialExact-02.html" ,
259
299
code = {
260
300
x <- gsBinomialExact(
@@ -294,10 +334,10 @@ testthat::test_that(
294
334
)
295
335
296
336
297
- # Test gsBinomial Exact for lower futility & upper efficacy bounday crossing
337
+ # Test gsBinomial Exact for lower futility & upper efficacy boundary crossing
298
338
# probabilities : Benchmark values have been obtained from East 6.5
299
339
testthat :: test_that(
300
- desc = " Test gsBinomial Exact for lower futility & upper efficacy bounday crossing
340
+ desc = " Test gsBinomial Exact for lower futility & upper efficacy boundary crossing
301
341
probabilities : Benchmark values have been obtained from East 6.5 :BinomialExact-03.html" ,
302
342
code = {
303
343
x <- gsBinomialExact(
@@ -378,3 +418,31 @@ testthat::test_that(
378
418
}
379
419
)
380
420
421
+ # ## Test binomialPP by comparing with gsBinomialExact
422
+ testthat :: test_that(" Testing binomialPP by comparing with gsBinomialExact" , {
423
+ a <- 0.2
424
+ b <- 0.8
425
+ theta <- c(0.2 , 0.4 )
426
+ p1 <- 0.4
427
+ PP <- c(0.025 , 0.95 )
428
+ nIA <- c(50 , 100 )
429
+ upper <- nIA + 1
430
+ lower <- rep(- 1 , length(nIA ))
431
+ j <- 1
432
+ for (i in nIA ) {
433
+ q <- 0 : i
434
+ post <- stats :: pbeta(p1 , a + q , b + i - q , lower.tail = F )
435
+ upper [j ] <- sum(post < PP [2 ])
436
+ lower [j ] <- sum(post < = PP [1 ])
437
+ j <- j + 1
438
+ }
439
+
440
+ ns <- binomialPP(a = a , b = b , theta = theta , p1 = p1 , PP = PP , nIA = nIA )
441
+
442
+ nz <- gsBinomialExact(k = 2 , theta = theta , a = lower , b = upper , n.I = nIA )
443
+
444
+ testthat :: expect_equal(ns $ lower $ bound , nz $ lower $ bound , info = " Checking lower bound" )
445
+ testthat :: expect_equal(ns $ lower $ prob , nz $ lower $ prob , info = " Checking lower probability" )
446
+ testthat :: expect_equal(ns $ upper $ bound , nz $ upper $ bound , info = " Checking upper bound" )
447
+ testthat :: expect_equal(ns $ upper $ prob , nz $ upper $ prob , info = " Checking upper probability" )
448
+ })
0 commit comments