Skip to content

Commit d1c9bbf

Browse files
carrieinteractiveCarrie LiaudreyyeoCHdanielinteractive
authored
fix size_look bug in ocPredprob dec 2 (#122)
Co-authored-by: Carrie Li <carrie@inferential.bio> Co-authored-by: Audrey Yeo <comptesaudrey@gmail.com> Co-authored-by: Daniel Sabanes Bove <daniel.sabanesbove@gmx.net> Co-authored-by: Daniel Sabanes Bove <danielinteractive@users.noreply.github.com>
1 parent 22bbad6 commit d1c9bbf

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

R/ocPredprob.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ h_get_decision_two_predprob <- function(nnr, truep, p0, p1, parE = c(1, 1), nnE,
163163
index_look <- index_look + 1
164164
}
165165
if (is.na(decision)) {
166+
size_look <- nnr[index_look]
166167
if (size_look %in% nnE) { # for efficacy looks at FINAL
167168
final_qU <- postprob(
168169
# based on all data, the posterior probability is a GO when P(p > p0) > tT

tests/testthat/test-ocPredprob.R

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ test_that("the PrFutility increases with increase futility looks", {
9191
test_that("the PrEfficacy increases with increase Efficacy looks", {
9292
set.seed(1989)
9393
expect_warning(result_eff <- ocPredprob(
94-
nnE = c(10, 20),
95-
truep = 0.6,
94+
nnE = 5,
95+
truep = 0.7,
9696
p0 = 0.2,
9797
p1 = 0.2,
9898
tT = 0.6,
@@ -106,8 +106,8 @@ test_that("the PrEfficacy increases with increase Efficacy looks", {
106106
decision1 = FALSE
107107
), "Advise to use sim >= 50000 to achieve convergence")
108108
expect_warning(result_more_eff <- ocPredprob(
109-
nnE = c(10, 20, 40),
110-
truep = 0.6,
109+
nnE = c(5, 20, 40),
110+
truep = 0.7,
111111
p0 = 0.2,
112112
p1 = 0.2,
113113
tT = 0.6,
@@ -122,3 +122,24 @@ test_that("the PrEfficacy increases with increase Efficacy looks", {
122122
), "Advise to use sim >= 50000 to achieve convergence")
123123
expect_true(result_more_eff$oc$PrEfficacy > result_eff$oc$PrEfficacy)
124124
})
125+
126+
test_that("ocPredprob correctly shows maximum sample size when no decision reached", {
127+
set.seed(40) # Used for reproducibility
128+
res1 <- ocPredprob(
129+
nnE = c(19, 39),
130+
truep = 0.4,
131+
p0 = 0.9,
132+
p1 = 0.1,
133+
phiU = 0.9,
134+
tT = 0.8,
135+
tF = 0.5,
136+
phiFu = 0.9,
137+
parE = c(2 / 6, 1 - 2 / 6),
138+
sim = 100,
139+
wiggle = FALSE,
140+
decision1 = FALSE
141+
)
142+
na_dec_ind <- which(is.na(res1$Decision))
143+
expect_true(length(na_dec_ind) > 0)
144+
expect_true(all(res1$SampleSize[na_dec_ind] > 19))
145+
})

0 commit comments

Comments
 (0)