Skip to content

Commit

Permalink
Merge pull request #376 from Merck/vignette-style
Browse files Browse the repository at this point in the history
Improve boundary update vignette code style
  • Loading branch information
LittleBeannie authored Apr 8, 2024
2 parents b690cc1 + 9b56345 commit 384a01c
Showing 1 changed file with 54 additions and 46 deletions.
100 changes: 54 additions & 46 deletions vignettes/articles/story-update-boundary.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ knitr::opts_chunk$set(echo = TRUE)

```{r, message=FALSE, warning=FALSE}
library(gsDesign2)
library(tibble)
library(gt)
library(dplyr)
```

# Design assumptions
Expand Down Expand Up @@ -118,13 +116,13 @@ over the targeted 90\%.
x |>
summary() |>
as_gt() |>
gt::tab_header(title = "Original design") |>
gt::tab_style(
tab_header(title = "Original design") |>
tab_style(
style = list(
gt::cell_fill(color = "lightcyan"),
gt::cell_text(weight = "bold")
cell_fill(color = "lightcyan"),
cell_text(weight = "bold")
),
locations = gt::cells_body(
locations = cells_body(
columns = Z,
rows = Bound == "Efficacy"
)
Expand Down Expand Up @@ -152,32 +150,37 @@ observed_data <- simtrial::sim_pw_surv(
)
observed_data_ia <- observed_data |> simtrial::cut_data_by_date(analysis_time[1])
observed_data_fa <- observed_data |> simtrial::cut_data_by_date(analysis_time[2])
observed_data_fa <- observed_data |> simtrial::cut_data_by_date(analysis_time[2])
```

The updated design is
```{r}
gs_update_ahr(x = x,
ia_alpha_spending = "actual_info_frac",
fa_alpha_spending = "full_alpha",
observed_data = list(observed_data_ia, observed_data_fa)) |>
summary(col_vars = c("analysis", "bound", "z", "~hr at bound",
"nominal p", "Alternate hypothesis", "Null hypothesis"),
col_decimals = c(NA, NA, 4, 4, 4, 4, 4)) |>
gs_update_ahr(
x = x,
ia_alpha_spending = "actual_info_frac",
fa_alpha_spending = "full_alpha",
observed_data = list(observed_data_ia, observed_data_fa)
) |>
summary(
col_vars = c(
"analysis", "bound", "z", "~hr at bound",
"nominal p", "Alternate hypothesis", "Null hypothesis"
),
col_decimals = c(NA, NA, 4, 4, 4, 4, 4)
) |>
as_gt() |>
gt::tab_style(
tab_style(
style = list(
gt::cell_fill(color = "lightcyan"),
gt::cell_text(weight = "bold")
cell_fill(color = "lightcyan"),
cell_text(weight = "bold")
),
locations = gt::cells_body(
locations = cells_body(
columns = Z,
rows = Bound == "Efficacy"
)
)
```


# Two-sided asymmetric design, beta-spending with non-binding lower bound {.tabset}

In this section, we investigate a 2 sided asymmetric design, with the
Expand Down Expand Up @@ -232,62 +235,67 @@ larger than what we have in the 1-sided example.
x |>
summary() |>
as_gt() |>
gt::tab_header(title = "Original design") |>
gt::tab_style(
tab_header(title = "Original design") |>
tab_style(
style = list(
gt::cell_fill(color = "lightcyan"),
gt::cell_text(weight = "bold")
cell_fill(color = "lightcyan"),
cell_text(weight = "bold")
),
locations = gt::cells_body(
locations = cells_body(
columns = Z,
rows = Bound == "Efficacy"
)
) |>
gt::tab_style(
tab_style(
style = list(
gt::cell_fill(color = "#F9E3D6"),
gt::cell_text(weight = "bold")
cell_fill(color = "#F9E3D6"),
cell_text(weight = "bold")
),
locations = gt::cells_body(
locations = cells_body(
columns = Z,
rows = Bound == "Futility"
)
)
```

For simplicity in presentation, we assume the observed events are the same as that in the 1-sided design.
For simplicity in presentation, we assume the observed events are the same as that in the 1-sided design.

The updated design is
```{r}
gs_update_ahr(x = x,
ia_alpha_spending = "actual_info_frac",
fa_alpha_spending = "full_alpha",
observed_data = list(observed_data_ia, observed_data_fa)) |>
summary(col_vars = c("analysis", "bound", "z", "~hr at bound",
"nominal p", "Alternate hypothesis", "Null hypothesis"),
col_decimals = c(NA, NA, 4, 4, 4, 4, 4)) |>
gs_update_ahr(
x = x,
ia_alpha_spending = "actual_info_frac",
fa_alpha_spending = "full_alpha",
observed_data = list(observed_data_ia, observed_data_fa)
) |>
summary(
col_vars = c(
"analysis", "bound", "z", "~hr at bound",
"nominal p", "Alternate hypothesis", "Null hypothesis"
),
col_decimals = c(NA, NA, 4, 4, 4, 4, 4)
) |>
as_gt() |>
gt::tab_style(
tab_style(
style = list(
gt::cell_fill(color = "lightcyan"),
gt::cell_text(weight = "bold")
cell_fill(color = "lightcyan"),
cell_text(weight = "bold")
),
locations = gt::cells_body(
locations = cells_body(
columns = Z,
rows = Bound == "Efficacy"
)
) |>
gt::tab_style(
tab_style(
style = list(
gt::cell_fill(color = "#F9E3D6"),
gt::cell_text(weight = "bold")
cell_fill(color = "#F9E3D6"),
cell_text(weight = "bold")
),
locations = gt::cells_body(
locations = cells_body(
columns = Z,
rows = Bound == "Futility"
)
)
```


# References

0 comments on commit 384a01c

Please sign in to comment.