Skip to content

Commit 2a221b2

Browse files
committed
ocPostprob.. tests clean
1 parent b6b5918 commit 2a221b2

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

tests/testthat/test-ocPostprob.R

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,31 +163,43 @@ test_that("ocPostprob gives results that are within range to stats::pbinom", {
163163
expect_true(abs(p.stop - result$oc$PrFutility) < 1e-2)
164164
})
165165

166-
test_that("two function calls that differ in parE does not give the same result.", {
166+
test_that("two ocPostprob calls that differ in parE does not give the same result.", {
167167
set.seed(1989)
168-
expect_warning(result_uniform_hard_coded <- ocPostprob(
168+
input <- list(
169169
nnE = c(10, 20, 30),
170170
truep = 0.3,
171171
p0 = 0.1,
172172
p1 = 0.2,
173173
tL = 0.8,
174174
tU = 0.8,
175-
parE = c(1, 1), # will fail in old code that was hard coded in uniform prior
175+
parE = c(4, 7), # Thall & Simon (p. 339, 1994) note on using informative a priori
176176
sim = 100,
177177
wiggle = TRUE,
178178
nnF = c(10, 20, 30)
179+
)
180+
expect_warning(result_uniform_hard_coded <- ocPostprob(
181+
nnE = input$nnE,
182+
truep = input$truep,
183+
p0 = input$p0,
184+
p1 = input$p1,
185+
tL = input$tL,
186+
tU = input$tU,
187+
parE = c(1, 1), # will fail in old code that was hard coded in uniform prior
188+
sim = input$sim,
189+
wiggle = TRUE,
190+
nnF = input$nnF
179191
), "Advise to use sim >= 50000 to achieve convergence")
180192
expect_warning(result_no_hard_code <- ocPostprob(
181-
nnE = c(10, 20, 30),
182-
truep = 0.3,
183-
p0 = 0.1,
184-
p1 = 0.2,
185-
tL = 0.8,
186-
tU = 0.8,
187-
parE = c(4, 7), # stronger prior gives higher PrEfficacy
188-
sim = 100,
193+
nnE = input$nnE,
194+
truep = input$truep,
195+
p0 = input$p0,
196+
p1 = input$p1,
197+
tL = input$tL,
198+
tU = input$tU,
199+
parE = input$parE, # will fail in old code that was hard coded in uniform prior
200+
sim = input$sim,
189201
wiggle = TRUE,
190-
nnF = c(10, 20, 30)
202+
nnF = input$nnF
191203
), "Advise to use sim >= 50000 to achieve convergence")
192204
expect_true(
193205
sum(result_no_hard_code$oc["PrEarlyEff"], result_no_hard_code$oc["PrEfficacy"]) >

tests/testthat/test-ocPostprobDist.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ test_that("the PrEfficacy increases with increase Efficacy looks", {
167167
expect_true(res_more_eff$oc$PrEfficacy > res_eff$oc$PrEfficacy)
168168
})
169169

170-
test_that("two function calls that differ in parE does not give the same result.", {
170+
test_that("two ocPostprobDist calls that differ in parE does not give the same result.", {
171171
set.seed(198)
172172
input <- list(
173173
nnE = c(10, 20, 30),
@@ -176,7 +176,7 @@ test_that("two function calls that differ in parE does not give the same result.
176176
deltaF = 0.2,
177177
tL = 0.6,
178178
tU = 0.6,
179-
parE = c(10, 4),
179+
parE = c(10, 4), # # Thall & Simon (p. 339, 1994) note on using informative a priori
180180
parS = c(1, 1),
181181
sim = 500,
182182
wiggle = FALSE,

tests/testthat/test-ocRctPostprobDist.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ test_that("ocRctPostprobDist gives higher PrEfficacy with increased pE", {
227227
expect_true(res_high_truep$oc$PrEfficacy > res_eff$oc$PrEfficacy)
228228
})
229229

230-
test_that("two function calls that differ in parE does not give the same result.", {
230+
test_that("Two ocRctPostprobDist calls that differ in parE does not give the same result.", {
231231
set.seed(1989)
232232
input <- list(
233233
nnE = c(10, 20, 30),

0 commit comments

Comments
 (0)