Skip to content

Commit 67986b3

Browse files
committed
remove AHR examples and will save them in a vignette
1 parent c6c3b59 commit 67986b3

File tree

2 files changed

+7
-158
lines changed

2 files changed

+7
-158
lines changed

R/gs_cp_npe.R

Lines changed: 3 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -43,84 +43,12 @@
4343
#' library(gsDesign2)
4444
#' library(dplyr)
4545
#'
46-
#' # ---------------------------------- #
47-
#' # Example 1 #
48-
#' # CP under arbitrary theta and info #
49-
#' # ---------------------------------- #
46+
#' # Calculate conditional power under arbitrary theta and info
47+
#' # In practice, the value of theta and info commonly comes from a design.
48+
#' # More examples are available at the pkgdown vignettes.
5049
#' gs_cp_npe(theta = c(.1, .2),
5150
#' info = c(15, 35),
5251
#' a = 1.5, b = 1.96)
53-
#'
54-
#' # ---------------------------------- #
55-
#' # Example 2 #
56-
#' # Calculate conditional power and #
57-
#' # error of a design #
58-
#' # ---------------------------------- #
59-
#' x <- gs_design_ahr(
60-
#' fail_rate = define_fail_rate(duration = c(4, Inf),
61-
#' fail_rate = log(2) / 10,
62-
#' hr = c(1, 0.7),
63-
#' dropout_rate = 0.0001),
64-
#' analysis_time = c(12, 24, 36))
65-
#'
66-
#' # Example 2A ----
67-
#' # Conditional error of FA given IA1 Z-score of 1.75
68-
#' gs_cp_npe(theta = c(0, 0),
69-
#' info = x$analysis$info0[c(1, 3)],
70-
#' a = 1.75,
71-
#' b = x$bound$z[x$bound$bound == "upper" & x$bound$analysis == 3])
72-
#'
73-
#' # Example 2B ----
74-
#' # Conditional power of FA given
75-
#' # (1) IA1 Z-score of 1.75;
76-
#' # (2) H1 assumed treatment effect
77-
#' gs_cp_npe(theta = x$analysis$theta[c(1, 3)],
78-
#' # taking info0 in this example gives minor differences
79-
#' info = x$analysis$info[c(1, 3)],
80-
#' a = 1.75,
81-
#' b = x$bound$z[x$bound$bound == "upper" & x$bound$analysis == 3])
82-
#'
83-
#' # Example 2C ----
84-
#' # Assume at IA1:
85-
#' # (1) The Z-score is 1.75;
86-
#' # (2) There are 50 events observed during the first 4 months since study starts
87-
#' # (3) There are 150 events observed after the 4th month.
88-
#' # For IA1, we take the blinded estimation of theta and info.
89-
#' # For FA, we take the planned theta and info.
90-
#' theta_blinded <- -sum(log(c(1, 0.7)) * c(50, 150)) / 200
91-
#' info_blinded <- 200 / 4
92-
#' gs_cp_npe(theta = c(theta_blinded, x$analysis$theta[3]),
93-
#' info = c(info_blinded, x$analysis$info0[3]),
94-
#' a = 1.75,
95-
#' b = x$bound$z[x$bound$bound == "upper" & x$bound$analysis == 3])
96-
#'
97-
#' # Example 2D ----
98-
#' # If the HR is not assumed, say, HR = 1 for the first 4 months and 0.8 afterwards
99-
#' # At FA, assume there are 70 events during the first 4 months and 700 events afterwards.
100-
#' # We first calculate the expected events at IA1 under the new HR
101-
#' e_event_ia1 <- expected_event(enroll_rate = x$enroll_rate,
102-
#' fail_rate = x$fail_rate |> mutate(hr = c(1, 0.8)),
103-
#' total_duration = x$analysis$time[1],
104-
#' simple = FALSE)
105-
#' # Under the new HR, there are 150 events during the first 4 months and 67 events afterwards.
106-
#' # If 160 and 67 are the blinded events, we can derive the blinded estimation of treatment effect.
107-
#' theta_blinded_ia1 <- -sum(log(c(1, 0.8)) * c(150, 67)) / (150 + 67)
108-
#' info_blinded_ia1 <- (150 + 67) / 4
109-
#'
110-
#' # We further calculate the expected events at FA under the new HR
111-
#' e_event_fa <- expected_event(enroll_rate = x$enroll_rate,
112-
#' fail_rate = x$fail_rate |> mutate(hr = c(1, 0.8)),
113-
#' total_duration = x$analysis$time[3],
114-
#' simple = FALSE)
115-
#' # Under the new HR, there are 223 events during the first 4 months and 562 events afterwards.
116-
#' # If 160 and 67 are the blinded events, we can derive the blinded estimation of treatment effect.
117-
#' theta_blinded_fa <- -sum(log(c(1, 0.8)) * c(223, 562)) / (223 + 562)
118-
#' info_blinded_fa <- (223 + 562) / 4
119-
#'
120-
#' gs_cp_npe(theta = c(theta_blinded_ia1, theta_blinded_fa),
121-
#' info = c(info_blinded_ia1, info_blinded_fa),
122-
#' a = 1.75,
123-
#' b = x$bound$z[x$bound$bound == "upper" & x$bound$analysis == 3])
12452
gs_cp_npe <- function(theta = NULL,
12553
info = NULL,
12654
a = NULL, b = NULL
@@ -140,15 +68,8 @@ gs_cp_npe <- function(theta = NULL,
14068
stop("Please provide info (statistical information given the treatment effect theta) to calculate conditional power.")
14169
}
14270

143-
if (max(info) > max_info) {
144-
stop("The max(info) should be smaller than max_info.")
145-
}
146-
14771
check_info(info)
14872

149-
# calculate information fraction
150-
info_frac <- info / max_info
151-
15273
# ----------------------------------------- #
15374
# calculate conditional power under theta #
15475
# ----------------------------------------- #

man/gs_cp_npe.Rd

Lines changed: 4 additions & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)