Skip to content

Commit 2453cdc

Browse files
committed
ocPostprobDist test checked
1 parent d2e9b3d commit 2453cdc

File tree

1 file changed

+39
-24
lines changed

1 file changed

+39
-24
lines changed

tests/testthat/test-ocPostprobDist.R

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -168,33 +168,48 @@ test_that("the PrEfficacy increases with increase Efficacy looks", {
168168
})
169169

170170
test_that("two function calls that differ in parE does not give the same result.", {
171-
set.seed(1989)
172-
expect_warning(result_uniform_hard_coded <- ocPostprobDist(
171+
set.seed(198)
172+
input <- list(
173173
nnE = c(10, 20, 30),
174-
truep = 0.15,
174+
truep = 0.7,
175175
deltaE = 0.1,
176-
deltaF = 0.1,
177-
tL = 0.45,
178-
tU = 0.4,
179-
parE = c(1, 1), # PrGrayZone higher due to same, weak priors
176+
deltaF = 0.2,
177+
tL = 0.6,
178+
tU = 0.6,
179+
parE = c(10, 4), # will fail in old code that was hard coded in uniform prior
180180
parS = c(1, 1),
181-
sim = 100,
181+
sim = 500,
182182
wiggle = FALSE,
183-
nnF = 30
184-
), "Advise to use sim >= 50000 to achieve convergence")
183+
nnF = c(10, 20, 30)
184+
)
185+
expect_warning(result_uniform_hard_coded <- ocPostprobDist(
186+
nnE = input$nnE,
187+
truep = input$truep,
188+
deltaE = input$deltaE,
189+
deltaF = input$deltaF,
190+
tL = input$tL,
191+
tU = input$tU,
192+
parE = c(1, 1),
193+
parS = input$parS,
194+
sim = input$sim,
195+
wiggle = input$wiggle,
196+
nnF = input$nnF), "Advise to use sim >= 50000 to achieve convergence")
185197
expect_warning(result_no_hard_code <- ocPostprobDist(
186-
nnE = c(10, 20, 30),
187-
truep = 0.15,
188-
deltaE = 0.1,
189-
deltaF = -0.1,
190-
tL = 0.45,
191-
tU = 0.4,
192-
parE = c(5, 10), # PrFutility lower due to stronger prior
193-
parS = c(1, 1),
194-
sim = 100,
195-
wiggle = FALSE,
196-
nnF = 30
197-
), "Advise to use sim >= 50000 to achieve convergence")
198-
expect_true(result_no_hard_code$oc["PrFutility"] > result_uniform_hard_coded$oc["PrFutility"])
199-
expect_true(result_no_hard_code$oc["PrGrayZone"] < result_uniform_hard_coded$oc["PrGrayZone"])
198+
nnE = input$nnE,
199+
truep = input$truep,
200+
deltaE = input$deltaE,
201+
deltaF = input$deltaF,
202+
tL = input$tL,
203+
tU = input$tU,
204+
parE = input$parE,
205+
parS = input$parS,
206+
sim = input$sim,
207+
wiggle = input$wiggle,
208+
nnF = input$nnF), "Advise to use sim >= 50000 to achieve convergence")
209+
result_uniform_hard_coded$oc
210+
result_no_hard_code$oc
211+
expect_true(sum(result_no_hard_code$oc["PrEarlyEff"], result_no_hard_code$oc["PrEfficacy"]) >
212+
sum(result_uniform_hard_coded$oc["PrEarlyEff"], result_uniform_hard_coded$oc["PrEfficacy"])
213+
)
200214
})
215+

0 commit comments

Comments
 (0)