Skip to content

Commit dc64376

Browse files
committed
Style code (GHA)
1 parent 4d951fd commit dc64376

3 files changed

Lines changed: 61 additions & 56 deletions

File tree

R/calc_seq_p.R

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -80,37 +80,38 @@
8080
#' )
8181
#' }
8282
calc_seq_p <- function(
83-
test_analysis = 2,
84-
test_hypothesis = "H1, H2, H3",
85-
p_obs = tibble::tibble(
86-
analysis = 1:2,
87-
H1 = c(0.02, 0.0015),
88-
H2 = c(0.01, 0.01),
89-
H3 = c(0.01, 0.004)
83+
test_analysis = 2,
84+
test_hypothesis = "H1, H2, H3",
85+
p_obs = tibble::tibble(
86+
analysis = 1:2,
87+
H1 = c(0.02, 0.0015),
88+
H2 = c(0.01, 0.01),
89+
H3 = c(0.01, 0.004)
90+
),
91+
alpha_spending_type = 2,
92+
n_analysis = 2,
93+
initial_weight = c(0.3, 0.3, 0.4),
94+
transition_mat = matrix(c(
95+
0.0000000, 0.4285714, 0.5714286,
96+
0.4285714, 0.0000000, 0.5714286,
97+
0.5000000, 0.5000000, 0.0000000
98+
), nrow = 3, byrow = TRUE),
99+
z_corr = matrix(
100+
c(
101+
1.0000000, 0.7627701, 0.6666667, 0.7071068, 0.5393599, 0.4714045,
102+
0.7627701, 1.0000000, 0.6992059, 0.5393599, 0.7071068, 0.4944132,
103+
0.6666667, 0.6992059, 1.0000000, 0.4714045, 0.4944132, 0.7071068,
104+
0.7071068, 0.5393599, 0.4714045, 1.0000000, 0.7627701, 0.6666667,
105+
0.5393599, 0.7071068, 0.4944132, 0.7627701, 1.0000000, 0.6992059,
106+
0.4714045, 0.4944132, 0.7071068, 0.6666667, 0.6992059, 1.0000000
90107
),
91-
alpha_spending_type = 2,
92-
n_analysis = 2,
93-
initial_weight = c(0.3, 0.3, 0.4),
94-
transition_mat = matrix(c(
95-
0.0000000, 0.4285714, 0.5714286,
96-
0.4285714, 0.0000000, 0.5714286,
97-
0.5000000, 0.5000000, 0.0000000
98-
), nrow = 3, byrow = TRUE),
99-
z_corr = matrix(
100-
c(
101-
1.0000000, 0.7627701, 0.6666667, 0.7071068, 0.5393599, 0.4714045,
102-
0.7627701, 1.0000000, 0.6992059, 0.5393599, 0.7071068, 0.4944132,
103-
0.6666667, 0.6992059, 1.0000000, 0.4714045, 0.4944132, 0.7071068,
104-
0.7071068, 0.5393599, 0.4714045, 1.0000000, 0.7627701, 0.6666667,
105-
0.5393599, 0.7071068, 0.4944132, 0.7627701, 1.0000000, 0.6992059,
106-
0.4714045, 0.4944132, 0.7071068, 0.6666667, 0.6992059, 1.0000000
107-
),
108-
nrow = 6, byrow = TRUE
109-
),
110-
spending_fun = gsDesign::sfHSD,
111-
spending_fun_par = -4,
112-
info_frac = c(0.5, 1),
113-
interval = c(1e-4, 0.2)) {
108+
nrow = 6, byrow = TRUE
109+
),
110+
spending_fun = gsDesign::sfHSD,
111+
spending_fun_par = -4,
112+
info_frac = c(0.5, 1),
113+
interval = c(1e-4, 0.2)
114+
) {
114115
foo <- function(x) {
115116
all_hypothesis <- strsplit(test_hypothesis, split = ", ") %>% unlist()
116117
all_hypothesis_idx <- as.numeric(gsub(".*?([0-9]+).*", "\\1", all_hypothesis))

tests/testthat/test-independent-generate_bounds.R

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ test_that("BH bounds replicate tables A6 and A7", {
391391
expect_equal(wA6_result1_test, round(wA6_result1, 4))
392392

393393

394-
395394
wA6_result2 <- c(
396395
0.00019939,
397396
0.000422943,
@@ -484,7 +483,6 @@ test_that("BH bounds replicate tables A6 and A7", {
484483
expect_equal(A7_result2_test, round(A7_result2, 4))
485484

486485

487-
488486
A7_result3 <- c(
489487
3.582064348,
490488
NA,
@@ -507,9 +505,6 @@ test_that("BH bounds replicate tables A6 and A7", {
507505
expect_equal(A7_result3_test, round(A7_result3, 4))
508506

509507

510-
511-
512-
513508
# Table A7
514509
wA7_result1 <- c(
515510
3.509232997,
@@ -556,7 +551,6 @@ test_that("BH bounds replicate tables A6 and A7", {
556551
expect_equal(wA7_result2_test, round(wA7_result2, 4))
557552

558553

559-
560554
wA7_result3 <- c(
561555
3.570376445,
562556
NA,

vignettes/dunnett_dose.Rmd

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ only).
137137
event <- tribble(
138138
~H1, ~H2, ~Analysis, ~Event,
139139
# IA diagonal (total events per hypothesis = dose + control)
140-
1, 1, 1, 49, # Dose 1 (24) + Control (25)
141-
2, 2, 1, 51, # Dose 2 (26) + Control (25)
142-
3, 3, 1, 50, # Dose 3 (25) + Control (25)
143-
4, 4, 1, 52, # Dose 4 (27) + Control (25)
140+
1, 1, 1, 49, # Dose 1 (24) + Control (25)
141+
2, 2, 1, 51, # Dose 2 (26) + Control (25)
142+
3, 3, 1, 50, # Dose 3 (25) + Control (25)
143+
4, 4, 1, 52, # Dose 4 (27) + Control (25)
144144
# IA off-diagonal (shared events = control only)
145145
1, 2, 1, 25,
146146
1, 3, 1, 25,
@@ -149,10 +149,10 @@ event <- tribble(
149149
2, 4, 1, 25,
150150
3, 4, 1, 25,
151151
# FA diagonal (total events per hypothesis = dose + control)
152-
1, 1, 2, 123, # Dose 1 (60) + Control (63)
153-
2, 2, 2, 128, # Dose 2 (65) + Control (63)
154-
3, 3, 2, 126, # Dose 3 (63) + Control (63)
155-
4, 4, 2, 130, # Dose 4 (67) + Control (63)
152+
1, 1, 2, 123, # Dose 1 (60) + Control (63)
153+
2, 2, 2, 128, # Dose 2 (65) + Control (63)
154+
3, 3, 2, 126, # Dose 3 (63) + Control (63)
155+
4, 4, 2, 130, # Dose 4 (67) + Control (63)
156156
# FA off-diagonal (shared events = control only)
157157
1, 2, 2, 63,
158158
1, 3, 2, 63,
@@ -210,26 +210,34 @@ cat("Corr(Z_1,1, Z_1,1) =", corr[1, 1], " (expected: 1.0)\n")
210210
# Case 2: Different hypotheses, same analysis (IA)
211211
# Corr(Z_1,1, Z_2,1) = n_control_IA / sqrt(n_H1_IA * n_H2_IA) = 25 / sqrt(49 * 51)
212212
expected_12_ia <- 25 / sqrt(49 * 51)
213-
cat("Corr(Z_1,1, Z_2,1) =", round(corr[1, 2], 6),
214-
" (expected:", round(expected_12_ia, 6), ")\n")
213+
cat(
214+
"Corr(Z_1,1, Z_2,1) =", round(corr[1, 2], 6),
215+
" (expected:", round(expected_12_ia, 6), ")\n"
216+
)
215217
216218
# Case 3: Different hypotheses, same analysis (FA)
217219
# Corr(Z_1,2, Z_3,2) = n_control_FA / sqrt(n_H1_FA * n_H3_FA) = 63 / sqrt(123 * 126)
218220
expected_13_fa <- 63 / sqrt(123 * 126)
219-
cat("Corr(Z_1,2, Z_3,2) =", round(corr[5, 7], 6),
220-
" (expected:", round(expected_13_fa, 6), ")\n")
221+
cat(
222+
"Corr(Z_1,2, Z_3,2) =", round(corr[5, 7], 6),
223+
" (expected:", round(expected_13_fa, 6), ")\n"
224+
)
221225
222226
# Case 4: Same hypothesis, different analyses
223227
# Corr(Z_1,1, Z_1,2) = n_H1_IA / sqrt(n_H1_IA * n_H1_FA) = 49 / sqrt(49 * 123)
224228
expected_11_cross <- 49 / sqrt(49 * 123)
225-
cat("Corr(Z_1,1, Z_1,2) =", round(corr[1, 5], 6),
226-
" (expected:", round(expected_11_cross, 6), ")\n")
229+
cat(
230+
"Corr(Z_1,1, Z_1,2) =", round(corr[1, 5], 6),
231+
" (expected:", round(expected_11_cross, 6), ")\n"
232+
)
227233
228234
# Case 5: Different hypotheses, different analyses
229235
# Corr(Z_2,1, Z_4,2) = n_control_min(IA) / sqrt(n_H2_IA * n_H4_FA) = 25 / sqrt(51 * 130)
230236
expected_24_cross <- 25 / sqrt(51 * 130)
231-
cat("Corr(Z_2,1, Z_4,2) =", round(corr[2, 8], 6),
232-
" (expected:", round(expected_24_cross, 6), ")\n")
237+
cat(
238+
"Corr(Z_2,1, Z_4,2) =", round(corr[2, 8], 6),
239+
" (expected:", round(expected_24_cross, 6), ")\n"
240+
)
233241
```
234242

235243
The correlation matrix for this 4-hypothesis Dunnett scenario has the
@@ -266,8 +274,8 @@ gs_design <- gsDesign(
266274
alpha = 0.025 / 4, # Per-hypothesis alpha (Bonferroni for single hypothesis)
267275
beta = 0.1,
268276
timing = IF_avg,
269-
sfu = sfLDOF, # Lan-DeMets O'Brien-Fleming for efficacy
270-
sfl = sfHSD, # HSD for futility
277+
sfu = sfLDOF, # Lan-DeMets O'Brien-Fleming for efficacy
278+
sfl = sfHSD, # HSD for futility
271279
sflpar = -2
272280
)
273281
@@ -278,8 +286,10 @@ futility_p <- pnorm(futility_z)
278286
cat("Information fraction:", round(IF_avg, 3), "\n")
279287
cat("Futility Z-bound at IA:", round(futility_z, 4), "\n")
280288
cat("Futility p-value bound at IA:", round(futility_p, 4), "\n")
281-
cat("Interpretation: Stop for futility if one-sided p-value >",
282-
round(futility_p, 4), "\n")
289+
cat(
290+
"Interpretation: Stop for futility if one-sided p-value >",
291+
round(futility_p, 4), "\n"
292+
)
283293
```
284294

285295
```{r}

0 commit comments

Comments
 (0)