Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/ocPredprob.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ h_get_decision_one_predprob <- function(nnr, truep, p0, parE = c(1, 1), nnE, nnF
thetaT = tT,
parE = parE
)$result
decision <- ifelse(interim_qU > phiU, FALSE, decision)
decision <- ifelse(interim_qU > phiU, TRUE, decision)
all_looks <- orig_nnr[index_look]
}
if (size_look %in% nnF) {
Expand Down
28 changes: 28 additions & 0 deletions tests/testthat/test-ocPredprob.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,34 @@ test_that("h_get_decision_one_predprob gives correct result and list", {
expect_list(result)
})

test_that("Go decision for all interims when criteria met for decision 1", {
set.seed(40)
expect_warning(
res <- ocPredprob(
decision1 = TRUE,
nnE = c(20, 30, 40),
nnF = c(20, 30, 40),
truep = 0.90,
phiU = 0.75,
phiL = 0.20,
tT = 0.70,
p0 = 0.20,
parE = c(0.2, 0.8),
sim = 100
),
"Advise to use sim >= 50000 to achieve convergence"
)
random_number <- sample(x = length(res$Decision), size = 1)
expect_true(all(res$Decision) == TRUE)
expect_true(all(res$SampleSize == 20))
expect_true(res$params$decision1 == TRUE)
expect_equal(res$oc$ExpectedN, res$SampleSize[random_number])
expect_identical(res$oc$PrEfficacy, 1)
expect_identical(res$oc$PrEarlyEff, 1)
expect_identical(res$oc$PrEarlyFut, 0)
expect_identical(res$oc$PrFutility, 0)
})

# h_get_decision_two_predprob ----
test_that("h_get_decision_two_predprob gives correct result and list", {
set.seed(1989)
Expand Down
Loading