Skip to content

Commit

Permalink
Merge pull request #426 from Merck/summary_upar
Browse files Browse the repository at this point in the history
summary function updated to correctly extract the full alpha level + test for this added
  • Loading branch information
LittleBeannie authored Jun 27, 2024
2 parents 3792965 + 2d982cf commit 5e6a9a5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -692,12 +692,14 @@ summary.gs_design <- function(object,
# Save the full alpha as an attribute of the output summary table
attr(output, "full_alpha") <-
if (is.null(object$input$alpha)) {
if (is.null(object$upar$total_spend)) {
# case when given sample size to calculate power
if (!is.list(object$input$upar)) {
0.025
} else {
object$upar$total_spend
object$input$upar$total_spend
}
} else {
# case when given power to calcuate sample size
object$input$alpha
}

Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/test-developer-summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,21 @@ test_that("The column 'Bound' is always included in summary.gs_design() output",
)
expect_true("Bound" %in% colnames(observed))
})


test_that("The full alpha is correctly carried over", {
a_level <- 0.02
x <- gs_power_ahr(
upper = gs_spending_bound,
upar = list(
sf = gsDesign::sfLDOF,
total_spend = a_level
),
test_lower = FALSE
)

# without col_vars
observed <- summary(x)

expect_equal(attributes(observed)$full_alpha, a_level)
})

0 comments on commit 5e6a9a5

Please sign in to comment.