Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
audreyyeoCH committed Nov 18, 2023
1 parent 6d79c5d commit 67d1022
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
12 changes: 4 additions & 8 deletions R/postprobDist.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ NULL
#' The helper function to generate Integrand function when `relative Delta = TRUE`.
#'
#' @typed delta : number
#' the margin of which treatment group `E` is superior than the success rate of
#' the standard of care `S`. See also note about the calculation of `delta` when `relative Delta = TRUE`.
#' margin by which the response rate in the treatment group should
#' be better than in the SOC group. Must be >= `0`. See note.
#' @typed p_s : number
#' probability of success or response rate of standard of care or `SOC` group.
#' @typed activeBetamixPost : list
Expand Down Expand Up @@ -86,11 +86,10 @@ h_get_bounds <- function(controlBetamixPost) {
#' @description `r lifecycle::badge("experimental")`
#'
#' Using the approach by Thall and Simon (Biometrics, 1994), this evaluates the
#' posterior probability of achieving superior response rate in the treatment group compared to standard of care (SOC):
#'
#' `Pr(P_E > P_S | data) = \int 1-F(p_s + delta | alpha_E + x, beta_E + n- x) f(p_s; alpha_S, beta_S`.
#' posterior probability of achieving superior response rate in the treatment group compared to standard of care (SOC).
#' See note below for two formulations of the difference in response rates.
#'
#' @inheritParams h_integrand_relDelta
#' @typed x : numeric
#' number of success counts in the treatment group.
#' @typed n : number
Expand All @@ -99,9 +98,6 @@ h_get_bounds <- function(controlBetamixPost) {
#' number of success counts in the SOC group.
#' @typed nS : number
#' number of patients in the SOC group.
#' @typed delta : number
#' margin by which the response rate in the treatment group should
#' be better than in the SOC group. Must be >= `0`. See note.
#' @typed relativeDelta : flag
#' If `TRUE`, then a `relativeDelta` is used. Represents that a minimum
#' response rate in magnitude of `delta` of the SOC non-responding patients. See note.
Expand Down
4 changes: 2 additions & 2 deletions examples/postprobDist.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ postprobDist(
delta = 0.1
)

# Experimental arm only (strictly single arm trial), uniform prior in Experimental arm. Default used.
# Experimental arm only (strictly single arm trial), uniform prior in Experimental arm.
# Non-uniform Prior used for SOC arm as no precedent data.
postprobDist(
x = 16,
Expand All @@ -56,7 +56,7 @@ postprobDist(
delta = 0,
relativeDelta = FALSE,
parS = c(2, 3),
weightsS = c(1)
weightsS = 1
)
# Experimental arm and SOC, uniform prior in both E and S arms, default setting used.
postprobDist(
Expand Down
4 changes: 2 additions & 2 deletions man/h_integrand.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/h_integrand_relDelta.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions man/postprobDist.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/testthat/test-postprobDist.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test_that("postprobDist gives incrementally higher values with larger x", {
expect_true(is_lower < is_higher)
})

test_that("postprobDist gives incrementally higher values with larger x", {
test_that("postprobDist gives higher values with larger x and returns identical result when x is a vector", {
expected_lower <- postprobDist(x = 16, n = 23, delta = 0.1, parE = c(0.6, 0.4), parS = c(0.6, 0.4))
expected_higher <- postprobDist(x = 20, n = 23, delta = 0.1, parE = c(0.6, 0.4), parS = c(0.6, 0.4))
result <- postprobDist(x = c(16, 20), n = 23, delta = 0.1, parE = c(0.6, 0.4), parS = c(0.6, 0.4))
Expand All @@ -35,7 +35,7 @@ test_that("postprobDist gives the correct result for a beta-mixture example", {
expect_equal(result, 0.3143941, tolerance = 1e-5)
})

test_that("postprobDist gives incrementally higher values with increased x", {
test_that("postprobDist gives incrementally higher values with larger x for a beta-mixture example", {
is_lower <- postprobDist(
x = 10,
n = 23,
Expand Down Expand Up @@ -65,7 +65,7 @@ test_that("postprobDist gives incrementally higher values with increased x", {
expect_true(is_lower < is_higher)
})

test_that("postprobDist gives the correct result with a weighted beta-mixture", {
test_that("postprobDist gives the correct result for a weighted beta-mixture", {
result <- postprobDist(
x = 10,
n = 23,
Expand Down Expand Up @@ -109,7 +109,7 @@ test_that("postprobDist gives an error when xS and nS are not numbers", {
parS = c(0.6, 0.4),
weights = c(0.5),
weightsS = c(0.3),
), "number of items to replace is not a multiple of replacement length"
), "Must have length 1"
)
})

Expand Down

0 comments on commit 67d1022

Please sign in to comment.