Install
$ agentstack add skill-choxos-biostatagent-advanced-adaptive-trials ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Advanced Adaptive Trial Designs in R
Overview
Advanced adaptive clinical trial designs including platform trials, basket and umbrella trials, response-adaptive randomization, multi-arm multi-stage designs, Bayesian adaptive methods, and sample size re-estimation techniques.
Platform Trials
Using adaptr Package
library(adaptr)
# Define a platform trial with multiple arms
setup
setup_trial_binom(
highest_is_best = TRUE,
soften_power = 0.5 # Softening for allocation
)
# Add arm dropping rules
setup
add_arm(
arm = "Arm_C",
true_y = 0.50,
start_look = 3 # Add at third interim
)
# Simulate
sims_platform p0
fit_mem$post_prob
# Cluster map (which baskets share information)
plot(fit_mem, type = "cluster")
Hierarchical Model for Baskets
library(basket)
# Full Bayesian hierarchical model
fit_hier p0) > 0.975
qc = 0.10, # Futility: P(rate > p0) < 0.10
lower.tail = FALSE
)
# Operating characteristics
oc <- oc2S(
prior_treatment = robust_prior,
prior_control = robust_prior,
n1_treatment = 30, # Stage 1 treatment
n1_control = 30, # Stage 1 control
n2_treatment = 30, # Stage 2 treatment
n2_control = 30, # Stage 2 control
decision = decision
)
# Plot OC curves
plot(oc)
# Type I error and power
summary(oc)
Group Sequential Designs with rpact
O'Brien-Fleming Design
library(rpact)
# O'Brien-Fleming group sequential design
design_of <- getDesignGroupSequential(
kMax = 3, # Number of stages
alpha = 0.025, # One-sided alpha
beta = 0.20, # Type II error
sided = 1,
typeOfDesign = "OF",
informationRates = c(0.33, 0.67, 1.0)
)
summary(design_of)
plot(design_of)
# Boundaries
design_of$criticalValues # Z-score boundaries
design_of$alphaSpent # Cumulative alpha spent
Sample Size Calculation
library(rpact)
# Sample size for survival endpoint
sample_size <- getSampleSizeSurvival(
design = design_of,
lambda1 = log(2) / 24, # Control median = 24 months
lambda2 = log(2) / 36, # Treatment median = 36 months (HR = 0.67)
accrualTime = 24, # Accrual period
followUpTime = 12, # Additional follow-up
dropoutRate1 = 0.05, # Control dropout
dropoutRate2 = 0.05, # Treatment dropout
allocationRatioPlanned = 1
)
summary(sample_size)
# Events and sample size at each look
sample_size$eventsPerStage
sample_size$numberOfSubjects
Interim Analysis
library(rpact)
# Perform interim analysis
interim <- getAnalysisResults(
design_of,
dataInput = getDataset(
n = c(100, 100), # Cumulative n by stage
events = c(40, 80), # Cumulative events by stage
logRanks = c(2.1, 2.8) # Log-rank Z statistics
)
)
summary(interim)
# Can the trial stop?
interim$finalStage # Final stage reached?
interim$futilityStop # Stopped for futility?
interim$rejectAtFinalStage # Rejected at final analysis?
Sample Size Re-Estimation
Blinded SSR
library(rpact)
# Sample size re-estimation based on interim data
ssr <- getSampleSizeReestimation(
design_of,
stageResults = interim,
conditionalPower = 0.80 # Target conditional power
)
summary(ssr)
ssr$sampleSizeNew # New sample size recommendation
Unblinded SSR
library(rpact)
# Conditional power at interim
cp <- getConditionalPower(
design = design_of,
stage = 2,
stageResults = interim,
nPlanned = c(50, 50), # Planned future n per arm
assumedEffect = 0.67 # Assumed treatment effect (HR)
)
summary(cp)
# If CP too low, calculate required sample size
if (cp$conditionalPower < 0.50) {
# Increase sample size
new_n <- getSampleSizeReestimation(design_of, interim, conditionalPower = 0.80)
}
Graphical Multiplicity with gMCP
library(gMCPLite)
# Define hypothesis graph
# H1, H2: Primary endpoints; H3, H4: Secondary endpoints
m <- matrix(
c(0, 0.5, 0.5, 0,
0.5, 0, 0, 0.5,
0.5, 0, 0, 0.5,
0, 0.5, 0.5, 0),
nrow = 4, byrow = TRUE
)
weights <- c(0.5, 0.5, 0, 0) # Initial alpha allocation
# Create graph
graph <- gMCP::matrix2graph(m, weights)
nodeNames(graph) <- c("H1_Primary", "H2_Primary", "H3_Secondary", "H4_Secondary")
# Plot
plot(graph)
# Test with p-values
pvalues <- c(0.01, 0.03, 0.02, 0.04)
result <- gMCP::gMCP(graph, pvalues, alpha = 0.025)
print(result)
# Which hypotheses rejected?
result@rejected
Key Packages Summary
| Package | Purpose | |---------|---------| | adaptr | Platform trial simulation | | basket | Basket trial analysis | | MAMS | Multi-arm multi-stage designs | | rpact | Group sequential and adaptive designs | | RBesT | Bayesian evidence synthesis | | gMCPLite | Graphical multiplicity procedures | | gsDesign | Group sequential designs | | gsDesign2 | Enhanced group sequential | | Mediana | Clinical trial simulations |
Best Practices
- Pre-specification: Define adaptation rules before trial starts
- Type I error: Ensure strong control under all adaptations
- Operating characteristics: Simulate extensively under various scenarios
- Blinding: Maintain blinding where possible during adaptations
- Documentation: Document all decision rules in protocol
- Regulatory: Engage regulators early for complex adaptive designs
- Implementation: Plan for operational complexity of adaptations
- Analysis: Plan for potential biases from adaptations
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: choxos
- Source: choxos/BiostatAgent
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.