clinical-trial-design
v0.0.12Phase 2/3 clinical trial design via gsDesign / gsDesign2: sample size, GS boundaries, multiplicity
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
design_binary
Use when the user wants two-arm Phase 2/3 sample size with a BINARY primary endpoint — responder rate, fixed-time mortality, ORR, ACR20, remission/cure, anything that resolves to event-or-no-event per subject. Set comparison='superiority' (default), 'non-inferiority' (then provide ni_margin), or 'equivalence' (then provide equiv_margin; fixed-sample only). Set design_class='group-sequential' for interim analyses with alpha-spending. Supply an optional `operational` block (any 0–4 of accrual_rate, accrual_duration, follow_up_duration, total_trial_duration) and the kernel fills in the rest.…
| Parameter | Type | Description |
|---|---|---|
p_control * | number | Event rate in the control arm (0,1). |
p_treatment * | number | Event rate in the treatment arm (0,1). |
allocation_ratio | number | Treatment / control allocation ratio. 1 = balanced 1:1. |
alpha | number | Type I error rate. For a standard two-sided 0.05 test use 0.025 with sided = 2. |
comparison | string | Hypothesis type. 'superiority' (default) tests for a difference; 'non-inferiority' requires ni_margin; 'equivalence' requires equiv_margin. |
design_class | string | Design class. 'fixed' = single final analysis; 'group-sequential' = interim looks with alpha-spending. Group-sequential params (k, timing, sfu/sfl, test_type) are ignored when design_class = 'fixed'. |
equiv_margin | number | Two-sided equivalence margin (TOST). Required when comparison='equivalence'. Fixed-sample only. |
k | integer | Number of planned analyses including the final one. Integer in [2, 10]. |
ni_margin | number | Non-inferiority margin on the risk-difference scale. Required when comparison='non-inferiority'. |
operational | object | Optional operational kernel inputs. Supply any 0-4 of {accrual_rate, accrual_duration, follow_up_duration, total_trial_duration}; the solver fills in the missing values from rate*duration = N and A +… |
power | number | 1 - beta. Targeted power of the test (default 0.9). |
sfl | Alpha-spending function. OF = O'Brien-Fleming, Pocock = Pocock, HSD = Hwang-Shih-DeCani (needs sfupar), Power = power family (needs sfupar), LDOF / LDPocock = Lan-DeMets approximations (the standard),… | |
sflpar | number | Numeric parameter for HSD / Power lower sf. |
sfu | string | Alpha-spending function. OF = O'Brien-Fleming, Pocock = Pocock, HSD = Hwang-Shih-DeCani (needs sfupar), Power = power family (needs sfupar), LDOF / LDPocock = Lan-DeMets approximations (the standard),… |
sfupar | number | Numeric parameter for HSD / Power upper sf. |
sided | number | 1 = one-sided test (default), 2 = two-sided. Many modern designs use sided = 1 with alpha = 0.025 to match the two-sided 0.05 convention. |
test_type | integer | gsDesign test.type. 1 = efficacy-only, 2 = symmetric efficacy+futility, 3 = non-binding futility, 4 = binding futility, 5/6 = same with lower beta-spending. |
timing | array | Information fractions at each analysis, length k, strictly increasing in (0,1], last = 1. Defaults to equal spacing 1/k, 2/k, ..., 1. |
design_continuous
Use when the user wants two-arm Phase 2/3 sample size with a CONTINUOUS primary endpoint — change from baseline in a measured score (HAM-D-17, PANSS, HbA1c reduction, eGFR slope, BP), QoL scale, biomarker level. Provide mean_diff (assumed treatment - control mean) and the common within-arm sd. Set comparison='superiority' (default), 'non-inferiority' (provide ni_margin), or 'equivalence' (provide equiv_margin; fixed-sample only). Set design_class='group-sequential' for interim analyses with alpha-spending. Supports the same `operational` block as design_binary and design_survival. For multi-…
| Parameter | Type | Description |
|---|---|---|
mean_diff * | number | Assumed mean difference (treatment - control). |
sd * | number | Common within-arm SD. |
allocation_ratio | number | Treatment / control allocation ratio. 1 = balanced 1:1. |
alpha | number | Type I error rate. For a standard two-sided 0.05 test use 0.025 with sided = 2. |
comparison | string | Hypothesis type. 'superiority' (default) tests for a difference; 'non-inferiority' requires ni_margin; 'equivalence' requires equiv_margin. |
design_class | string | Design class. 'fixed' = single final analysis; 'group-sequential' = interim looks with alpha-spending. Group-sequential params (k, timing, sfu/sfl, test_type) are ignored when design_class = 'fixed'. |
equiv_margin | number | Two-sided equivalence margin (TOST). Fixed-sample only. |
k | integer | Number of planned analyses including the final one. Integer in [2, 10]. |
ni_margin | number | Non-inferiority margin on the mean-difference scale. |
operational | object | Optional operational kernel inputs. Supply any 0-4 of {accrual_rate, accrual_duration, follow_up_duration, total_trial_duration}; the solver fills in the missing values from rate*duration = N and A +… |
power | number | 1 - beta. Targeted power of the test (default 0.9). |
sfl | Alpha-spending function. OF = O'Brien-Fleming, Pocock = Pocock, HSD = Hwang-Shih-DeCani (needs sfupar), Power = power family (needs sfupar), LDOF / LDPocock = Lan-DeMets approximations (the standard),… | |
sflpar | number | |
sfu | string | Alpha-spending function. OF = O'Brien-Fleming, Pocock = Pocock, HSD = Hwang-Shih-DeCani (needs sfupar), Power = power family (needs sfupar), LDOF / LDPocock = Lan-DeMets approximations (the standard),… |
sfupar | number | |
sided | number | 1 = one-sided test (default), 2 = two-sided. Many modern designs use sided = 1 with alpha = 0.025 to match the two-sided 0.05 convention. |
test_type | integer | gsDesign test.type. 1 = efficacy-only, 2 = symmetric efficacy+futility, 3 = non-binding futility, 4 = binding futility, 5/6 = same with lower beta-spending. |
timing | array | Information fractions at each analysis, length k, strictly increasing in (0,1], last = 1. Defaults to equal spacing 1/k, 2/k, ..., 1. |
design_survival
Use when the user wants Phase 2/3 sample size with a TIME-TO-EVENT primary endpoint — overall survival, PFS, time to first hospitalization, time to progression, time to a CV composite, etc. Choose the test statistic via `model`: 'ph' (default — log-rank under proportional hazards, gsDesign::nSurv / gsSurv), 'maxcombo' (delayed effect / non-proportional hazards via Fleming-Harrington combo), 'rmst' (restricted mean survival to landmark tau), 'milestone' (survival probability at landmark t*), 'wlr' / 'ahr' (weighted log-rank / average HR for GS NPH). Set design_class='group-sequential' for i…
| Parameter | Type | Description |
|---|---|---|
control_median * | number | Control-arm median survival (months). |
accrual_duration | number | Accrual period (months). |
accrual_rate | number | Enrollment rate (subjects/month). |
allocation_ratio | number | Treatment / control allocation ratio. 1 = balanced 1:1. |
alpha | number | Type I error rate. For a standard two-sided 0.05 test use 0.025 with sided = 2. |
analysis_times | array | Calendar times of k planned analyses (NPH GS); last = study duration. |
binding | boolean | Whether the futility boundary is binding (NPH GS). |
comparison | string | Hypothesis type. 'superiority' (default) tests for a difference; 'non-inferiority' requires ni_margin; 'equivalence' requires equiv_margin. |
delay_months | number | Duration of HR=1 period preceding the effect (NPH models). |
design_class | string | Design class. 'fixed' = single final analysis; 'group-sequential' = interim looks with alpha-spending. Group-sequential params (k, timing, sfu/sfl, test_type) are ignored when design_class = 'fixed'. |
dropout_rate | number | Per-month dropout hazard. |
followup_duration | number | Minimum follow-up after last enrollment (months). |
gamma | array | Fleming-Harrington gamma weights (MaxCombo / WLR). |
hazard_ratio | number | Target HR (PH only). < 1 favors treatment. For NI with hr_null > 1, the assumed true HR is often 1. |
hr_null | number | Null-hypothesis HR for non-inferiority (typically > 1, e.g. 1.3). |
k | integer | Number of planned analyses including the final one. Integer in [2, 10]. |
model | string | Survival statistical model. 'ph' = log-rank under proportional hazards (gsDesign::nSurv / gsSurv). 'maxcombo' / 'rmst' / 'milestone' are NPH fixed-sample (gsDesign2::fixed_design_*). 'wlr' / 'ahr' are… |
ni_hr | number | Alias for hr_null. |
operational | object | Optional operational kernel inputs. Supply any 0-4 of {accrual_rate, accrual_duration, follow_up_duration, total_trial_duration}; the solver fills in the missing values from rate*duration = N and A +… |
post_delay_hr | number | HR after delay_months (NPH models). |
power | number | 1 - beta. Targeted power of the test (default 0.9). |
reasoning_chain | array | Optional structured citation trail. Each entry: {decision, value, justification, source_type, source_ref?}. design_report() renders this inline; sponsor_confidential entries trigger a redaction prompt… |
rho | array | Fleming-Harrington rho weights (MaxCombo / WLR). |
sfl | Alpha-spending function. OF = O'Brien-Fleming, Pocock = Pocock, HSD = Hwang-Shih-DeCani (needs sfupar), Power = power family (needs sfupar), LDOF / LDPocock = Lan-DeMets approximations (the standard),… | |
sflpar | number | |
sfu | string | Alpha-spending function. OF = O'Brien-Fleming, Pocock = Pocock, HSD = Hwang-Shih-DeCani (needs sfupar), Power = power family (needs sfupar), LDOF / LDPocock = Lan-DeMets approximations (the standard),… |
sfupar | number | |
sided | number | TTE designs are one-sided. |
tau | number | Landmark time for RMST / milestone (months). Defaults to total study duration. |
tau_fh | Fleming-Harrington tau (MaxCombo / WLR). | |
test_type | integer | gsDesign test.type. 1 = efficacy-only, 2 = symmetric efficacy+futility, 3 = non-binding futility, 4 = binding futility, 5/6 = same with lower beta-spending. |
timing | array | Information fractions at each analysis, length k, strictly increasing in (0,1], last = 1. Defaults to equal spacing 1/k, 2/k, ..., 1. |
design_co_primary
Multi-endpoint co-primary trial design with multiplicity control. Use when a confirmatory trial requires positive results on two or more primary endpoints (oncology PFS+OS, CV death+HHF, etc.). Strategies: fixed-sequence (hierarchical, full alpha per test, the canonical approach for ordered co-primary), alpha-split (partition alpha by weights), bonferroni (equal alpha-split). Each endpoint is sized at its effective alpha via the matching design_<type> wrapper; total N is the max across endpoints. For graphical multiplicity (Maurer-Bretz with alpha recycling), use `design_graphical_multiplicity…
| Parameter | Type | Description |
|---|---|---|
endpoints * | object | Named map of co-primary endpoints. Each entry has `type` plus the parameters the matching design_<type> wrapper accepts (e.g., for survival: model, design_class, control_median, hazard_ratio, accrual_… |
allocation_ratio | number | Treatment-to-control allocation ratio, shared across endpoints. |
alpha | number | Family-wise type I error (default 0.025, one-sided). |
alpha_weights | object | For strategy='alpha-split' only. Named numeric vector summing to 1. Default (when omitted with alpha-split): equal weights 1/k. |
ordering | array | For strategy='fixed-sequence' only. Endpoint names in test order. Default: order in which `endpoints` was supplied. |
power | number | Per-endpoint power (default 0.80). |
reasoning_chain | array | Optional structured citation trail. Each entry: {decision, value, justification, source_type, source_ref?}. design_report() renders this inline; sponsor_confidential entries trigger a redaction prompt… |
sided | number | Sidedness. |
strategy | string | Multiplicity-control strategy. `fixed-sequence` (hierarchical) tests each endpoint at the full family alpha conditional on prior rejection — preserves alpha by closed testing, no per-test discount.… |
design_multi_population
Multi-population (subgroup) trial design with multiplicity control. Use when a confirmatory trial tests the same endpoint in multiple populations — biomarker-positive subgroup + ITT, nested PD-L1 strata, etc. Pick relation='nested' (the canonical case: TPS≥50 ⊂ TPS≥20 ⊂ ITT, all patients enroll into the broadest, total N driven by largest implied-enrolled across strata) or 'disjoint' (strata enrolled separately, total N = sum). Strategies: fixed-sequence (hierarchical), alpha-split, bonferroni. For graphical multiplicity (Maurer-Bretz with alpha recycling between populations), use de…
| Parameter | Type | Description |
|---|---|---|
endpoint_args * | object | Shared endpoint design parameters (e.g., for survival: model, design_class, control_median, accrual_duration, followup_duration, dropout_rate). The effect parameter (hazard_ratio / p_treatment / delta… |
endpoint_type * | string | Endpoint family — selects which design_<type> wrapper handles each population. |
populations * | object | Named map of populations. Each entry has `effect` (and `prevalence` for nested mode). |
allocation_ratio | number | |
alpha | number | |
alpha_weights | object | For strategy='alpha-split' only. Names match `populations`; sum to 1. |
ordering | array | For strategy='fixed-sequence' only. Population names in test order. |
power | number | |
reasoning_chain | array | Optional structured citation trail. Each entry: {decision, value, justification, source_type, source_ref?}. design_report() renders this inline; sponsor_confidential entries trigger a redaction prompt… |
relation | string | How populations relate. `nested` (default): subgroups overlap, all patients enroll into the broadest, total N = max of implied-enrolled-N. `disjoint`: separate strata enrolled, total N = sum of per-po… |
sided | number | |
strategy | string | Multiplicity-control strategy across populations. `fixed-sequence` is the canonical biomarker pattern (test strongest-effect subgroup first, gate broader strata on rejection). |
design_graphical_multiplicity
Graphical multiplicity (Maurer-Bretz) trial design with alpha recycling. Use when a confirmatory trial has 2+ hypotheses (mixed primary + secondary, dose-response, parent + derived endpoints) where a graph-based procedure preserves family-wise alpha better than Bonferroni. Validates the transition matrix (Rule-3 + row sums) and constructs a graphicalMCP graph object. Sizes each hypothesis at its worst-case alpha; total N is the max across hypotheses. For simpler co-primary or multi-population designs use design_co_primary or design_multi_population instead.
| Parameter | Type | Description |
|---|---|---|
hypotheses * | object | Named map of hypotheses. Each entry has `type` plus the parameters the matching design_<type> wrapper accepts. Continuous uses `mean_diff`, binary uses `p_treatment`, survival uses `hazard_ratio`. |
initial_weights * | object | Per-hypothesis initial alpha weights. Names match `hypotheses`; sum to <= 1. Hypotheses with weight 0 start un-testable and become testable only after alpha is recycled to them through the transition… |
transition_matrix * | array | Square (k x k) transition matrix. Row i column j = weight of alpha re-allocated from hypothesis i to hypothesis j upon rejection of i. Each row sums to <= 1; diagonal must be 0 (no self-loops). Order… |
allocation_ratio | number | |
alpha | number | |
gate_prereqs | object | Optional per-hypothesis prerequisite map. Each entry is the list of hypothesis names that must be rejected before this one can be tested. Used by the Rule-3 validator: every prerequisite must have a n… |
power | number | |
reasoning_chain | array | Optional structured citation trail. Each entry: {decision, value, justification, source_type, source_ref?}. design_report() renders this inline; sponsor_confidential entries trigger a redaction prompt… |
sided | number | |
worst_case_weights | object | Optional override of the per-hypothesis worst-case weight used for sample-size sizing. Default: max(initial_weight_i, fallback) where fallback = smallest non-zero initial weight. |
validate_against_benchmark
Load a benchmark corpus case, re-run the matching design wrapper with its inputs, and diff computed sample_size_total / events_total against expected within the case's tolerance.
| Parameter | Type | Description |
|---|---|---|
family * | string | Benchmark family directory name under benchmarks/ (e.g. 'fixed-superiority', 'group-sequential', 'tte-nph'). |
id * | string | Case ID = YAML filename without extension, e.g. '1997_CAPTURE_abciximab'. |
tool | string | Override the design tool to dispatch. If omitted, inferred from case metadata. |
verify_design
Monte Carlo simulation cross-check for a designr result. Closed-form simulation (rbinom / rnorm / rexp) drives empirical power and Type I error estimates against the design's target alpha and power. Supports fixed and group-sequential families on binary, continuous, and PH survival endpoints. NPH families (MaxCombo, RMST, milestone) and equivalence designs are not yet supported and return a clean error.
| Parameter | Type | Description |
|---|---|---|
result * | object | A designr result object as returned by any design_* tool (the JSON payload, including $method, $inputs, and (for GS) $boundaries / $timing). |
n_sim | integer | Monte Carlo replicate count. Default 5000. |
seed | integer | RNG seed for reproducibility. Default 1. |
tolerance_power_pp | number | Allowed deviation from target power, in percentage points. Default 2. |
tolerance_type_I_pp | number | Allowed deviation from target alpha, in percentage points. Default 0.5. |
design_report
Render a clinician-readable design summary in markdown, Word, or PDF. Reasoning chain (when populated on the result) appears as a table; sponsor_confidential entries trigger a redaction warning at the top. Sections: title, design overview, key inputs, headline output, GS analysis plan, reasoning chain, method + version. Default output is markdown text; format='docx' returns a native Word file path (officer); format='pdf' renders via rmarkdown + Pandoc.
| Parameter | Type | Description |
|---|---|---|
result * | object | A designr result object as returned by any design_* tool (the JSON payload, including $method, $inputs, and (for GS) $boundaries / $timing). |
format | string | Output format. 'markdown' (default) returns the report as text. 'docx' writes a native Word document via the officer R package; 'pdf' renders via rmarkdown + Pandoc (requires Pandoc + a TeX engine on… |
path | string | For format='docx' or 'pdf': output file path. If omitted, a tempfile is created and its path returned in the result. |