Skip to content

Generate textual summary as gsDesign #526

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

Merged
merged 11 commits into from
Apr 18, 2025

Conversation

LittleBeannie
Copy link
Collaborator

@LittleBeannie LittleBeannie commented Apr 10, 2025

To fix issue #525.

Textual summary of 1-sided design:

> x <- gs_design_ahr(info_frac = 1:3/3, test_lower = FALSE)
> x |> text_summary()
[1] "One-sided group sequential design with 3 analyses, time-to-event outcome with sample size 489.9 and 300.4 events, 90 percent power, 2.5 percent (1-sided) Type I error to detect hazard ratio of 0.9 during the first 3 months and 0.6 thereafter. Enrollment and total study durations are assumed to be 14 and 36 months, respectively. Efficacy bounds derived using a Lan-DeMets O'Brien-Fleming approximation spending function (no parameters)."

> x |> to_integer() |> text_summary()
[1] "One-sided group sequential design with 3 analyses, time-to-event outcome with sample size 490 and 301 events, 90 percent power, 2.5 percent (1-sided) Type I error to detect hazard ratio of 0.9 during the first 3 months and 0.6 thereafter. Enrollment and total study durations are assumed to be 14 and 36.1 months, respectively. Efficacy bounds derived using a Lan-DeMets O'Brien-Fleming approximation spending function (no parameters)."

> gs_power_ahr(event = c(10, 20, 30), test_lower = FALSE) |> text_summary()
[1] "One-sided group sequential design with 3 analyses, time-to-event outcome with sample size 108 and 30 events, 2.5 percent (1-sided) Type I error. Enrollment and total study durations are assumed to be 14 and 14.9 months, respectively. Efficacy bounds derived using a Lan-DeMets O'Brien-Fleming approximation spending function (no parameters). With hazard ratio of 0.9 during the first 3 months and 0.6 thereafter, the power is 9 percent."

> gs_power_ahr(event = c(10, 20, 30), test_lower = FALSE) |> to_integer() |> text_summary()
[1] "One-sided group sequential design with 3 analyses, time-to-event outcome with sample size 108 and 30 events, 2.5 percent (1-sided) Type I error. Enrollment and total study durations are assumed to be 14 and 14.9 months, respectively. Efficacy bounds derived using a Lan-DeMets O'Brien-Fleming approximation spending function (no parameters). With hazard ratio of 0.9 during the first 3 months and 0.6 thereafter, the power is 9 percent."

Textual summary of a 2-sided symmetric design

> x <- gs_design_ahr(info_frac = 1:3/3,
+                    upper = gs_spending_bound, lower = gs_spending_bound,
+                    upar = list(sf = sfLDOF, total_spend = 0.025),
+                    lpar = list(sf = sfLDOF, total_spend = 0.025),
+                    binding = TRUE, h1_spending = FALSE) |> to_integer()
> x |> text_summary()
[1] "Symmetric two-sided group sequential design with 3 analyses, time-to-event outcome with sample size 490 and 301 events, 90 percent power, 2.5 percent (1-sided) Type I error to detect hazard ratio of 0.9 during the first 3 months and 0.6 thereafter. Enrollment and total study durations are assumed to be 14 and 36.1 months, respectively. Bounds derived using a  Lan-DeMets O'Brien-Fleming approximation spending function (no parameters)."

Textual summary of a asymmetric 2-sided design with beta-spending and non-binding futility bound

> x <- gs_design_ahr(info_frac = 1:3/3, alpha = 0.025, beta = 0.1,
+                    upper = gs_spending_bound, lower = gs_spending_bound,
+                    upar = list(sf = sfLDOF, total_spend = 0.025),
+                    lpar = list(sf = sfHSD, total_spend = 0.1, param = -4),
+                    binding = FALSE, h1_spending = TRUE) |> to_integer()
> x |> text_summary()
[1] "Asymmetric two-sided group sequential design with non-binding futility bound, 3 analyses, time-to-event outcome with sample size 500 and 306 events, 90 percent power, 2.5 percent (1-sided) Type I error to detect hazard ratio of 0.9 during the first 3 months and 0.6 thereafter. Enrollment and total study durations are assumed to be 14 and 35.9 months, respectively. Efficacy bounds derived using a Lan-DeMets O'Brien-Fleming approximation spending function (no parameters). Futility bounds derived using a Hwang-Shih-DeCani spending function with gamma = -4."

Textual summary of a asymmetric 2-sided design with fixed non-binding futility bound

> x <- gs_design_ahr(info_frac = 1:3/3, alpha = 0.025, beta = 0.1,
+                    upper = gs_spending_bound, lower = gs_b,
+                    upar = list(sf = sfLDOF, total_spend = 0.025),
+                    test_upper = c(FALSE, TRUE, TRUE),
+                    lpar = c(-1, -Inf, -Inf),
+                    test_lower = c(TRUE, FALSE, FALSE),
+                    binding = FALSE, h1_spending = TRUE) |> to_integer()
> x |> text_summary()
[1] "Asymmetric two-sided group sequential design with non-binding futility bound, 3 analyses, time-to-event outcome with sample size 506 and 311 events, 90 percent power, 2.5 percent (1-sided) Type I error to detect hazard ratio of 0.9 during the first 3 months and 0.6 thereafter. Enrollment and total study durations are assumed to be 14 and 36.1 months, respectively. Efficacy bounds derived using a Lan-DeMets O'Brien-Fleming approximation spending function (no parameters), tested at tested at IA2, FA. Futility bounds is fixed as -1, -Inf, -Inf, tested at tested at IA1."

If there are >5 pieces of HRs, we provide a brief summary of HR.

gs_design_ahr(
+   fail_rate = define_fail_rate(duration = c(rep(3, 5), Inf),
+                                hr = c(0.9, 0.8, 0.7, 0.6, 0.5, 0.4),
+                                fail_rate = log(2) / 10, dropout_rate = 0.001),
+   info_frac = 1:3/3, test_lower = FALSE) |>
+   text_summary()
[1] "One-sided group sequential design with 3 analyses, time-to-event outcome with sample size 290.5 and 218 events, 90 percent power, 2.5 percent (1-sided) Type I error to detect piecewise hazard ratio. Enrollment and total study durations are assumed to be 14 and 36 months, respectively. Efficacy bounds derived using a Lan-DeMets O'Brien-Fleming approximation spending function (no parameters)."

@LittleBeannie LittleBeannie added this to the 2025 Q2 milestone Apr 10, 2025
@LittleBeannie LittleBeannie self-assigned this Apr 10, 2025
@LittleBeannie LittleBeannie linked an issue Apr 10, 2025 that may be closed by this pull request
@LittleBeannie LittleBeannie requested a review from keaven April 10, 2025 23:31
@keaven
Copy link
Collaborator

keaven commented Apr 17, 2025

Looks good!

Copy link
Collaborator

@keaven keaven left a comment

Choose a reason for hiding this comment

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

Looks good!

@LittleBeannie LittleBeannie merged commit c36ff72 into main Apr 18, 2025
7 checks passed
@LittleBeannie LittleBeannie deleted the 525-generate-text-summary-as-gsdesign branch April 18, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate text summary as gsDesign
2 participants