Skip to content

Commit aa2539f

Browse files
committed
improve narrative
1 parent 0ee3f24 commit aa2539f

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

inst/app/modules/mod_narrative.R

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ mod_narrative_server <- function(
4141
)
4242
} else {
4343
sprintf(
44-
"This design simulates a two-arm trial to %s, using a one-sided significance level of %s.",
44+
"This design simulates a two-arm trial to %s. The threshold γ is calibrated to control the Type-I error at %s.",
4545
margin_txt, fmt_pct(alpha())
4646
)
4747
}
@@ -57,35 +57,28 @@ mod_narrative_server <- function(
5757
# 4. Prior description
5858
prior_type <- switch(
5959
prior(),
60-
"flat" = "a non-informative flat prior (Beta(1,1))",
61-
"power" = sprintf(
62-
"a power prior (discount a₀ = %.0f%%) incorporating %s/%s historical responders and a baseline Beta prior (%.1f, %.1f)",
63-
100 * prior_args()$a0,
64-
fmt_int(prior_args()$y_0),
65-
fmt_int(prior_args()$n_0),
66-
prior_args()$a_base %||% 1,
67-
prior_args()$b_base %||% 1
68-
)
60+
"flat" = "a non-informative flat prior for the response rate in each arm",
61+
"power" = {
62+
eff_n0 <- prior_args()$a0 * prior_args()$n_0
63+
sprintf(
64+
"a power prior incorporating %s/%s historical responders. The historical data is down-weighted using a factor of %.0f%%, resulting in an effective contribution equivalent to %.1f patients",
65+
fmt_int(prior_args()$y_0),
66+
fmt_int(prior_args()$n_0),
67+
100 * prior_args()$a0,
68+
eff_n0
69+
)
70+
}
6971
)
7072

71-
# 5. Decision logic
72-
decision_txt <- if (decision_mode() == "gamma") {
73-
sprintf("The trial is declared successful if the posterior probability that the true treatment effect exceeds Δ is at least γ = %s.", fmt_pct(gamma()))
74-
} else {
75-
sprintf("γ is calibrated to achieve a target Type-I error of %s.", fmt_pct(alpha()))
76-
}
77-
7873
# 6. Final narrative
7974
HTML(sprintf(
8075
"<p>%s</p>
81-
<p>%s</p>
8276
<p>%s</p>
8377
<p>The analysis uses %s.</p>
8478
<p>Posterior probabilities are computed using %s draws per simulated trial, across %s simulated trials.</p>
8579
<p>Seed = %s (for reproducibility).</p>",
8680
design_txt,
8781
arm_txt,
88-
decision_txt,
8982
prior_type,
9083
fmt_int(ndraws()), fmt_int(B()),
9184
fmt_int(seed())

0 commit comments

Comments
 (0)