Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move function to internal #261

Merged
merged 14 commits into from
Jul 18, 2023
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export(expected_accrual)
export(expected_event)
export(expected_time)
export(fixed_design)
export(gridpts)
export(gs_b)
export(gs_create_arm)
export(gs_design_ahr)
Expand All @@ -33,8 +32,6 @@ export(gs_power_rd)
export(gs_power_wlr)
export(gs_spending_bound)
export(gs_spending_combo)
export(h1)
export(hupdate)
export(ppwe)
export(s2pwe)
export(to_integer)
Expand Down
6 changes: 3 additions & 3 deletions R/gridpts_h1_hupdate.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#' }
#' \if{html}{The contents of this section are shown in PDF user manual only.}
#'
#' @export
#' @noRd
#'
#' @examples
#' # Approximate variance of standard normal (i.e., 1)
Expand Down Expand Up @@ -93,7 +93,7 @@ gridpts <- function(r = 18, mu = 0, a = -Inf, b = Inf) {
#' }
#' \if{html}{The contents of this section are shown in PDF user manual only.}
#'
#' @export
#' @noRd
#'
#' @examples
#' # Replicate variance of 1, mean of 35
Expand Down Expand Up @@ -137,7 +137,7 @@ h1 <- function(r = 18, theta = 0, info = 1, a = -Inf, b = Inf) {
#' }
#' \if{html}{The contents of this section are shown in PDF user manual only.}
#'
#' @export
#' @noRd
#'
#' @examples
#' # 2nd analysis with no interim bound and drift 0 should have mean 0, variance 1
Expand Down
33 changes: 0 additions & 33 deletions R/gs_spending_bound.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,39 +81,6 @@
#' @importFrom stats qnorm
#'
#' @export
#'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a little concerned that if it is okay to delete the examples of gs_spending_bound, considering it is an exported function,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many refer people to the vignettes?

Or we should create examples without h1() function

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we only show the 1st analysis bound, then we can get rid of h1. Otherwise, if we show the 2nd analysis bound, then we need h1. I personally feel the 2nd analysis is necessary... for the presentation of a comprehensive story.

I am open to referring people to vignettes in @examples, and will defer to @nanxstats for his suggestions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision: change the examples in gs_spending_bound as we have in gs_design_ahr.

#' @examples
#' info <- (1:3) * 10
#' info_frac <- info / max(info)
#' k <- length(info_frac)
#'
#' # 1st analysis
#' a1 <- gs_spending_bound(
#' k = 1, efficacy = FALSE, theta = 0,
#' par = list(sf = gsDesign::sfLDOF, total_spend = 0.025, timing = info_frac, param = NULL),
#' hgm1 = NULL
#' )
#'
#' b1 <- gs_spending_bound(
#' k = 1, efficacy = TRUE, theta = 0,
#' par = list(sf = gsDesign::sfLDOF, total_spend = 0.025, timing = info_frac, param = NULL),
#' hgm1 = NULL
#' )
#' cat("The (lower, upper) boundary at the 1st analysis is (", a1, ", ", b1, ").\n")
#'
#' # 2nd analysis
#' a2 <- gs_spending_bound(
#' k = 2, efficacy = FALSE, theta = 0,
#' par = list(sf = gsDesign::sfLDOF, total_spend = 0.025, timing = info_frac, param = NULL),
#' hgm1 = h1(r = 18, theta = 0, info = info[1], a = a1, b = b1)
#' )
#'
#' b2 <- gs_spending_bound(
#' k = 2, efficacy = TRUE, theta = 0,
#' par = list(sf = gsDesign::sfLDOF, total_spend = 0.025, timing = info_frac, param = NULL),
#' hgm1 = h1(r = 18, theta = 0, info = info[1], a = a1, b = b1)
#' )
#' cat("The upper boundary at the 2nd analysis is (", a2, ", ", b2, ").\n")
gs_spending_bound <- function(k = 1,
par = list(
sf = gsDesign::sfLDOF,
Expand Down
3 changes: 0 additions & 3 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ reference:
- expected_accrual
- ppwe
- s2pwe
- gridpts
- h1
- hupdate
- gs_create_arm

articles:
Expand Down
5 changes: 2 additions & 3 deletions inst/old_function/gs_power_npe_.R

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

58 changes: 0 additions & 58 deletions man/gridpts.Rd

This file was deleted.

33 changes: 0 additions & 33 deletions man/gs_spending_bound.Rd

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

53 changes: 0 additions & 53 deletions man/h1.Rd

This file was deleted.

62 changes: 0 additions & 62 deletions man/hupdate.Rd

This file was deleted.

12 changes: 6 additions & 6 deletions vignettes/articles/story-npe-integration.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ The columns in the resulting table are
```{r}
# Set up grid over continuation region
# Null hypothesis
grid1_0 <- h1(theta = 0, info = info[1], a = a1, b = b1)
grid1_0 <- gsDesign2:::h1(theta = 0, info = info[1], a = a1, b = b1)
grid1_0 %>% head()
```
The probability of not crossing a bound under the null hypothesis is computed as follows:
Expand All @@ -212,7 +212,7 @@ cat(
We now set up numerical integration grid under the alternate hypothesis and the compute continuation probability.

```{r}
grid1_1 <- h1(theta = theta[1], info = info[1], a = a1, b = b1)
grid1_1 <- gsDesign2:::h1(theta = theta[1], info = info[1], a = a1, b = b1)
prob_h1_continue <- sum(grid1_1$h)
h1mean <- sqrt(info[1]) * theta[1]
cat(
Expand Down Expand Up @@ -248,7 +248,7 @@ Under the null hypothesis, we need to update to the interval above `b2_0`.

```{r}
# Upper rejection region grid under H0
grid2_0 <- hupdate(theta = 0, info = info[2], a = b2_0, b = Inf, im1 = info[1], gm1 = grid1_0)
grid2_0 <- gsDesign2:::hupdate(theta = 0, info = info[2], a = b2_0, b = Inf, im1 = info[1], gm1 = grid1_0)
pupper_0 <- sum(grid2_0$h)
cat(
"Upper spending at analysis 2\n Target:", spend0, "\n Using initial bound approximation:",
Expand All @@ -272,7 +272,7 @@ cat(
"Original bound approximation:", b2_0,
"\nUpdated bound approximation:", b2_1
)
grid2_0 <- hupdate(theta = 0, info = info[2], a = b2_1, b = Inf, im1 = info[1], gm1 = grid1_0)
grid2_0 <- gsDesign2:::hupdate(theta = 0, info = info[2], a = b2_1, b = Inf, im1 = info[1], gm1 = grid1_0)
pupper_1 <- sum(grid2_0$h)
cat(
"\nOriginal boundary crossing probability:", pupper_0,
Expand All @@ -286,7 +286,7 @@ We now update the lower bound in an analogous fashion.

```{r}
# Lower rejection region grid under H1
grid2_1 <- hupdate(
grid2_1 <- gsDesign2:::hupdate(
theta = theta[2], info = info[2], a = -Inf, b = a2_0,
thetam1 = theta[1], im1 = info[1], gm1 = grid1_1
)
Expand All @@ -305,7 +305,7 @@ cat(
"\nUpdated bound approximation:", a2_1
)

grid2_1 <- hupdate(
grid2_1 <- gsDesign2:::hupdate(
theta = theta[2], info = info[2], a = -Inf, b = a2_1,
thetam1 = theta[1], im1 = info[1], gm1 = grid1_1
)
Expand Down
4 changes: 2 additions & 2 deletions vignettes/articles/usage-gs-spending-bound.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ cat("The (lower, upper) boundary at the 1st analysis is (", a1, ", ", b1, ").\n"
a2 <- gs_spending_bound(
k = 2, efficacy = FALSE, theta = 0,
par = list(sf = gsDesign::sfLDOF, total_spend = 0.025, timing = info_frac, param = NULL),
hgm1 = h1(r = 18, theta = 0, info = info[1], a = a1, b = b1)
hgm1 = gsDesign2:::h1(r = 18, theta = 0, info = info[1], a = a1, b = b1)
)

b2 <- gs_spending_bound(
k = 2, efficacy = TRUE, theta = 0,
par = list(sf = gsDesign::sfLDOF, total_spend = 0.025, timing = info_frac, param = NULL),
hgm1 = h1(r = 18, theta = 0, info = info[1], a = a1, b = b1)
hgm1 = gsDesign2:::h1(r = 18, theta = 0, info = info[1], a = a1, b = b1)
)
cat("The upper boundary at the 2nd analysis is (", a2, ", ", b2, ").\n")
```
Expand Down