Skip to content

Commit d8faf3a

Browse files
Merge pull request #187 from Merck/issue-185
Fix issues identified by CRAN
2 parents db0c735 + f2f0fab commit d8faf3a

34 files changed

+422
-137
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
^.*\.Rproj$
22
^\.Rproj\.user$
3+
^data-raw$
34
^_pkgdown\.yml$
45
^pkgdown$
56
^docs$
@@ -11,3 +12,4 @@
1112
^\.lintr$
1213
^vignettes/articles$
1314
^inst/check_with_old_version/.*\.html$
15+
^cran-comments\.md$

.lintr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ linters:
1010
exclusions:
1111
list(
1212
"inst/",
13-
"R/gridpts_h1_hupdate.R" = list(
14-
object_name_linter = Inf
15-
),
16-
"tests/testthat/fixtures/simu_test_gs_design_combo.R" = list(
13+
"data-raw/simu_test_gs_design_combo.R" = list(
1714
object_name_linter = Inf,
1815
commented_code_linter = Inf
1916
),

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: gsDesign2
22
Title: Group Sequential Design with Non-Constant Effect
3-
Version: 1.0.5
3+
Version: 1.0.6
44
Authors@R: c(
55
person("Keaven", "Anderson", email = "keaven_anderson@merck.com", role = c("aut")),
66
person("Yilong", "Zhang", email = "elong0527@gmail.com", role = c("aut")),

NAMESPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export(expected_accrual)
1212
export(expected_event)
1313
export(expected_time)
1414
export(fixed_design)
15+
export(gridpts)
1516
export(gs_b)
17+
export(gs_create_arm)
1618
export(gs_design_ahr)
1719
export(gs_design_combo)
1820
export(gs_design_npe)
@@ -29,6 +31,8 @@ export(gs_power_rd)
2931
export(gs_power_wlr)
3032
export(gs_spending_bound)
3133
export(gs_spending_combo)
34+
export(h1)
35+
export(hupdate)
3236
export(ppwe)
3337
export(s2pwe)
3438
export(to_integer)

NEWS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# gsDesign2 1.0.6
2+
3+
## Improvements
4+
5+
- Export functions `gridpts()`, `h1()`, `hupdate()`, and `gs_create_arm()`
6+
to avoid the use of `:::` in code examples.
7+
- Fix the write path issue by moving the test fixture generation script to
8+
`data-raw/` which is not included in the package.
9+
110
# gsDesign2 1.0.5
211

312
First submission to CRAN in March 2023.

R/gridpts_h1_hupdate.R

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#' }
5252
#' \if{html}{The contents of this section are shown in PDF user manual only.}
5353
#'
54-
#' @noRd
54+
#' @export
5555
#'
5656
#' @examples
5757
#' # Approximate variance of standard normal (i.e., 1)
@@ -71,7 +71,7 @@ gridpts <- function(r = 18, mu = 0, a = -Inf, b = Inf) {
7171
#'
7272
#' @param r Integer, at least 2; default of 18 recommended by Jennison and Turnbull.
7373
#' @param theta Drift parameter for first analysis.
74-
#' @param I Information at first analysis.
74+
#' @param info Information at first analysis.
7575
#' @param a Lower limit of integration (scalar).
7676
#' @param b Upper limit of integration (scalar `> a`).
7777
#'
@@ -93,19 +93,19 @@ gridpts <- function(r = 18, mu = 0, a = -Inf, b = Inf) {
9393
#' }
9494
#' \if{html}{The contents of this section are shown in PDF user manual only.}
9595
#'
96-
#' @noRd
96+
#' @export
9797
#'
9898
#' @examples
9999
#' # Replicate variance of 1, mean of 35
100-
#' g <- h1(theta = 5, I = 49)
100+
#' g <- h1(theta = 5, info = 49)
101101
#' mu <- sum(g$z * g$h)
102102
#' var <- sum((g$z - mu)^2 * g$h)
103103
#'
104104
#' # Replicate p-value of 0.0001 by numerical integration of tail
105105
#' g <- h1(a = qnorm(0.9999))
106106
#' sum(g$h)
107-
h1 <- function(r = 18, theta = 0, I = 1, a = -Inf, b = Inf) {
108-
h1_rcpp(r = r, theta = theta, I = I, a = a, b = b)
107+
h1 <- function(r = 18, theta = 0, info = 1, a = -Inf, b = Inf) {
108+
h1_rcpp(r = r, theta = theta, I = info, a = a, b = b)
109109
}
110110

111111
#' Update numerical integration for group sequential design
@@ -114,12 +114,18 @@ h1 <- function(r = 18, theta = 0, I = 1, a = -Inf, b = Inf) {
114114
#'
115115
#' @param r Integer, at least 2; default of 18 recommended by Jennison and Turnbull.
116116
#' @param theta Drift parameter for current analysis.
117-
#' @param I Information at current analysis.
117+
#' @param info Information at current analysis.
118118
#' @param a Lower limit of integration (scalar).
119119
#' @param b Upper limit of integration (scalar `> a`).
120120
#' @param thetam1 Drift parameter for previous analysis.
121-
#' @param Im1 Information at previous analysis.
121+
#' @param im1 Information at previous analysis.
122122
#' @param gm1 Numerical integration grid from [h1()] or previous run of [hupdate()].
123+
#'
124+
#' @return A list with grid points in `z`,
125+
#' numerical integration weights in `w`,
126+
#' a normal density with mean `mu = theta * sqrt{I}`
127+
#' and variance 1 times the weight in `h`.
128+
#'
123129
#' @section Specification:
124130
#' \if{latex}{
125131
#' \itemize{
@@ -131,18 +137,13 @@ h1 <- function(r = 18, theta = 0, I = 1, a = -Inf, b = Inf) {
131137
#' }
132138
#' \if{html}{The contents of this section are shown in PDF user manual only.}
133139
#'
134-
#' @return A list with grid points in `z`,
135-
#' numerical integration weights in `w`,
136-
#' a normal density with mean `mu = theta * sqrt{I}`
137-
#' and variance 1 times the weight in `h`.
138-
#'
139-
#' @noRd
140+
#' @export
140141
#'
141142
#' @examples
142143
#' # 2nd analysis with no interim bound and drift 0 should have mean 0, variance 1
143144
#' g <- hupdate()
144145
#' mu <- sum(g$z * g$h)
145146
#' var <- sum((g$z - mu)^2 * g$h)
146-
hupdate <- function(r = 18, theta = 0, I = 2, a = -Inf, b = Inf, thetam1 = 0, Im1 = 1, gm1 = h1()) {
147-
hupdate_rcpp(r = r, theta = theta, I = I, a = a, b = b, thetam1 = thetam1, Im1 = Im1, gm1 = gm1)
147+
hupdate <- function(r = 18, theta = 0, info = 2, a = -Inf, b = Inf, thetam1 = 0, im1 = 1, gm1 = h1()) {
148+
hupdate_rcpp(r = r, theta = theta, I = info, a = a, b = b, thetam1 = thetam1, Im1 = im1, gm1 = gm1)
148149
}

R/gs_power_npe.R

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,19 +297,19 @@ gs_power_npe <- function(theta = .1, theta0 = NULL, theta1 = NULL, # 3 theta
297297
0
298298
}
299299
# update the grids
300-
hgm1_0 <- h1(r = r, theta = theta0[1], I = info0[1], a = if (binding) {
300+
hgm1_0 <- h1(r = r, theta = theta0[1], info = info0[1], a = if (binding) {
301301
a[1]
302302
} else {
303303
-Inf
304304
}, b = b[1])
305-
hgm1_1 <- h1(r = r, theta = theta1[1], I = info1[1], a = a[1], b = b[1])
306-
hgm1 <- h1(r = r, theta = theta[1], I = info[1], a = a[1], b = b[1])
305+
hgm1_1 <- h1(r = r, theta = theta1[1], info = info1[1], a = a[1], b = b[1])
306+
hgm1 <- h1(r = r, theta = theta[1], info = info[1], a = a[1], b = b[1])
307307
} else {
308308
# compute the probability to cross upper bound
309309
upper_prob[k] <- if (b[k] < Inf) {
310310
sum(hupdate(
311311
theta = theta[k], thetam1 = theta[k - 1],
312-
I = info[k], Im1 = info[k - 1],
312+
info = info[k], im1 = info[k - 1],
313313
a = b[k], b = Inf, gm1 = hgm1, r = r
314314
)$h)
315315
} else {
@@ -319,7 +319,7 @@ gs_power_npe <- function(theta = .1, theta0 = NULL, theta1 = NULL, # 3 theta
319319
lower_prob[k] <- if (a[k] > -Inf) {
320320
sum(hupdate(
321321
theta = theta[k], thetam1 = theta[k - 1],
322-
I = info[k], Im1 = info[k - 1],
322+
info = info[k], im1 = info[k - 1],
323323
a = -Inf, b = a[k], gm1 = hgm1, r = r
324324
)$h)
325325
} else {
@@ -328,20 +328,20 @@ gs_power_npe <- function(theta = .1, theta0 = NULL, theta1 = NULL, # 3 theta
328328

329329
# update the grids
330330
if (k < n_analysis) {
331-
hgm1_0 <- hupdate(r = r, theta = theta0[k], I = info0[k], a = if (binding) {
331+
hgm1_0 <- hupdate(r = r, theta = theta0[k], info = info0[k], a = if (binding) {
332332
a[k]
333333
} else {
334334
-Inf
335-
}, b = b[k], thetam1 = 0, Im1 = info0[k - 1], gm1 = hgm1_0)
335+
}, b = b[k], thetam1 = 0, im1 = info0[k - 1], gm1 = hgm1_0)
336336
hgm1_1 <- hupdate(
337-
r = r, theta = theta1[k], I = info1[k],
337+
r = r, theta = theta1[k], info = info1[k],
338338
a = a[k], b = b[k], thetam1 = theta1[k - 1],
339-
Im1 = info1[k - 1], gm1 = hgm1_1
339+
im1 = info1[k - 1], gm1 = hgm1_1
340340
)
341341
hgm1 <- hupdate(
342-
r = r, theta = theta[k], I = info[k],
342+
r = r, theta = theta[k], info = info[k],
343343
a = a[k], b = b[k], thetam1 = theta[k - 1],
344-
Im1 = info[k - 1], gm1 = hgm1
344+
im1 = info[k - 1], gm1 = hgm1
345345
)
346346
}
347347
}

R/gs_spending_bound.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@
105105
#' a2 <- gs_spending_bound(
106106
#' k = 2, efficacy = FALSE, theta = 0,
107107
#' par = list(sf = gsDesign::sfLDOF, total_spend = 0.025, timing = info_frac, param = NULL),
108-
#' hgm1 = gsDesign2:::h1(r = 18, theta = 0, I = info[1], a = a1, b = b1)
108+
#' hgm1 = h1(r = 18, theta = 0, info = info[1], a = a1, b = b1)
109109
#' )
110110
#'
111111
#' b2 <- gs_spending_bound(
112112
#' k = 2, efficacy = TRUE, theta = 0,
113113
#' par = list(sf = gsDesign::sfLDOF, total_spend = 0.025, timing = info_frac, param = NULL),
114-
#' hgm1 = gsDesign2:::h1(r = 18, theta = 0, I = info[1], a = a1, b = b1)
114+
#' hgm1 = h1(r = 18, theta = 0, info = info[1], a = a1, b = b1)
115115
#' )
116116
#' cat("The upper boundary at the 2nd analysis is (", a2, ", ", b2, ").\n")
117117
gs_spending_bound <- function(k = 1,
@@ -217,9 +217,9 @@ gs_spending_bound <- function(k = 1,
217217
while (abs(adelta) > tol) {
218218
# get grid for rejection region
219219
hg <- hupdate(
220-
theta = theta[k], I = info[k], a = -Inf,
220+
theta = theta[k], info = info[k], a = -Inf,
221221
b = a, thetam1 = theta[k - 1],
222-
Im1 = info[k - 1], gm1 = hgm1, r = r
222+
im1 = info[k - 1], gm1 = hgm1, r = r
223223
)
224224
i <- length(hg$h)
225225

@@ -285,7 +285,7 @@ gs_spending_bound <- function(k = 1,
285285

286286
while (abs(bdelta) > tol) {
287287
# sub-density for final analysis in rejection region
288-
hg <- hupdate(theta = 0, I = info[k], a = b, b = Inf, thetam1 = 0, Im1 = info[k - 1], gm1 = hgm1, r = r)
288+
hg <- hupdate(theta = 0, info = info[k], a = b, b = Inf, thetam1 = 0, im1 = info[k - 1], gm1 = hgm1, r = r)
289289

290290
# compute probability of crossing bound
291291
pik <- sum(hg$h)

R/utility_wlr.R

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#' @inheritParams gs_info_ahr
2121
#' @param total_time Total analysis time.
2222
#'
23+
#' @return A list of the two arms.
24+
#'
2325
#' @section Specification:
2426
#' \if{latex}{
2527
#' \itemize{
@@ -44,7 +46,24 @@
4446
#' }
4547
#' \if{html}{The contents of this section are shown in PDF user manual only.}
4648
#'
47-
#' @noRd
49+
#' @export
50+
#'
51+
#' @examples
52+
#' enroll_rate <- tibble::tibble(
53+
#' stratum = "All",
54+
#' duration = c(2, 2, 10),
55+
#' rate = c(3, 6, 9)
56+
#' )
57+
#'
58+
#' fail_rate <- tibble::tibble(
59+
#' stratum = "All",
60+
#' duration = c(3, 100),
61+
#' fail_rate = log(2) / c(9, 18),
62+
#' hr = c(.9, .6),
63+
#' dropout_rate = rep(.001, 2)
64+
#' )
65+
#'
66+
#' gs_create_arm(enroll_rate, fail_rate, ratio = 1)
4867
gs_create_arm <- function(enroll_rate,
4968
fail_rate,
5069
ratio,

R/wlr_weight.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
#' dropout_rate = rep(.001, 2)
6868
#' )
6969
#'
70-
#' gs_arm <- gsDesign2:::gs_create_arm(enroll_rate, fail_rate, ratio = 1)
70+
#' gs_arm <- gs_create_arm(enroll_rate, fail_rate, ratio = 1)
7171
#' arm0 <- gs_arm$arm0
7272
#' arm1 <- gs_arm$arm1
7373
#'
@@ -110,7 +110,7 @@ wlr_weight_fh <- function(x, arm0, arm1, rho = 0, gamma = 0, tau = NULL) {
110110
#' dropout_rate = rep(.001, 2)
111111
#' )
112112
#'
113-
#' gs_arm <- gsDesign2:::gs_create_arm(enroll_rate, fail_rate, ratio = 1)
113+
#' gs_arm <- gs_create_arm(enroll_rate, fail_rate, ratio = 1)
114114
#' arm0 <- gs_arm$arm0
115115
#' arm1 <- gs_arm$arm1
116116
#'
@@ -140,7 +140,7 @@ wlr_weight_1 <- function(x, arm0, arm1) {
140140
#' dropout_rate = rep(.001, 2)
141141
#' )
142142
#'
143-
#' gs_arm <- gsDesign2:::gs_create_arm(enroll_rate, fail_rate, ratio = 1)
143+
#' gs_arm <- gs_create_arm(enroll_rate, fail_rate, ratio = 1)
144144
#' arm0 <- gs_arm$arm0
145145
#' arm1 <- gs_arm$arm1
146146
#'
@@ -175,7 +175,7 @@ wlr_weight_n <- function(x, arm0, arm1, power = 1) {
175175
#' dropout_rate = rep(.001, 2)
176176
#' )
177177
#'
178-
#' gs_arm <- gsDesign2:::gs_create_arm(enroll_rate, fail_rate, ratio = 1)
178+
#' gs_arm <- gs_create_arm(enroll_rate, fail_rate, ratio = 1)
179179
#' arm0 <- gs_arm$arm0
180180
#' arm1 <- gs_arm$arm1
181181
#'

0 commit comments

Comments
 (0)