Adaptive Trial Simulator
Statistical simulation platform for designing and validating adaptive clinical trial designs in silico. Enables optimization of interim analysis strategies, sample size adaptation, and early stopping rules while maintaining Type I error control.
Features
- - Design Simulation: Monte Carlo validation of adaptive designs
- Sample Size Re-estimation: Adapt sample size based on interim data
- Early Stopping Rules: Futility and efficacy boundary optimization
- Type I Error Control: Validate alpha spending strategies
- Multi-Arm Designs: Drop-the-loser and seamless Phase II/III
- Power Optimization: Identify designs with maximum power efficiency
Usage
Basic Usage
CODEBLOCK0
Parameters
| Parameter | Type | Default | Required | Description |
|---|
| INLINECODE0 | str | group_sequential | No | Trial design type |
| INLINECODE1 |
int | 10000 | No | Number of Monte Carlo simulations |
|
--sample-size | int | 200 | No | Initial sample size per arm |
|
--effect-size | float | 0.3 | No | Effect size (Cohen's d) |
|
--alpha | float | 0.05 | No | Type I error rate |
|
--power | float | 0.80 | No | Target statistical power |
|
--interim-looks | int | 1 | No | Number of interim analyses |
|
--spending-function | str | obrien_fleming | No | Alpha spending function |
|
--reestimate-method | str | promising_zone | No | Sample size re-estimation method |
|
--output | str | results.json | No | Output file path |
|
--visualize | flag | False | No | Generate visualization charts |
|
--optimize | flag | False | No | Search for optimal design parameters |
Advanced Usage
CODEBLOCK1
Design Types
| Design Type | Description | Use Case |
|---|
| Group Sequential | Fixed interim looks with stopping boundaries | Standard adaptive trials |
| Adaptive Re-estimate |
Sample size adjustment based on interim data | Uncertain effect size |
|
Drop the Loser | Multi-arm trials dropping inferior arms | Phase II dose selection |
Spending Functions
| Function | Characteristics | Early Boundary |
|---|
| O'Brien-Fleming | Conservative early | High Z-scores early |
| Pocock |
Aggressive early | Lower Z-scores throughout |
|
Power Family | Moderate (ρ=3) | Balanced approach |
Output Example
CODEBLOCK2
Technical Difficulty: HIGH
⚠️ AI自主验收状态: 需人工检查
This skill requires:
- - Python 3.8+ environment
- NumPy, SciPy, and Matplotlib packages
- Understanding of clinical trial statistics
Dependencies
CODEBLOCK3
Requirements
CODEBLOCK4
Risk Assessment
| Risk Indicator | Assessment | Level |
|---|
| Code Execution | Python scripts with mathematical calculations | Medium |
| Network Access |
No network access | Low |
| File System Access | Writes simulation results | Low |
| Instruction Tampering | Statistical parameters could affect results | Medium |
| Data Exposure | No sensitive data exposure | Low |
Security Checklist
- - [x] No hardcoded credentials or API keys
- [x] No unauthorized file system access
- [x] Output does not expose sensitive information
- [x] Input parameters validated
- [x] Error messages sanitized
- [x] Dependencies audited
Prerequisites
CODEBLOCK5
Evaluation Criteria
Success Metrics
- - [ ] Simulations run without errors
- [ ] Type I error controlled at nominal level
- [ ] Power estimates are accurate
- [ ] Visualizations generated correctly
Test Cases
- 1. Basic Simulation: Default parameters → Valid results
- Different Designs: All design types → Appropriate behavior
- Optimization Mode: --optimize flag → Finds optimal parameters
- Visualization: --visualize flag → Charts generated
Lifecycle Status
- - Current Stage: Draft
- Next Review Date: 2026-03-15
- Known Issues: Type checking warnings with numpy arrays
- Planned Improvements:
- Bayesian adaptive designs
- Multi-arm multi-stage (MAMS) support
- Enhanced visualization options
References
Available in references/:
- - Adaptive design statistical theory
- Regulatory guidance documents
- Alpha spending function literature
- Sample size re-estimation methods
Limitations
- - Statistical Complexity: Requires biostatistics expertise
- Simulation Time: Large simulations may take hours
- Simplified Models: Does not capture all real-world complexities
- Regulatory Consultation: Results should be validated with regulators
⚠️ DISCLAIMER: This tool provides simulation results for research and planning purposes only. All clinical trial designs should be reviewed by qualified biostatisticians and regulatory experts before implementation.
自适应试验模拟器
用于在计算机上设计和验证自适应临床试验设计的统计模拟平台。支持优化中期分析策略、样本量调整和提前终止规则,同时控制I类错误率。
功能特点
- - 设计模拟:自适应设计的蒙特卡洛验证
- 样本量重新估计:基于中期数据调整样本量
- 提前终止规则:无效性和有效性边界优化
- I类错误控制:验证alpha消耗策略
- 多臂设计:淘汰劣势组和无缝II/III期设计
- 效能优化:识别效能效率最高的设计
使用方法
基本用法
bash
运行标准组序贯设计
python scripts/main.py
带样本量重新估计的自适应设计
python scripts/main.py --design adaptive_reestimate
优化设计参数
python scripts/main.py --optimize
参数说明
| 参数 | 类型 | 默认值 | 必填 | 说明 |
|---|
| --design | 字符串 | group_sequential | 否 | 试验设计类型 |
| --n-simulations |
整数 | 10000 | 否 | 蒙特卡洛模拟次数 |
| --sample-size | 整数 | 200 | 否 | 每组初始样本量 |
| --effect-size | 浮点数 | 0.3 | 否 | 效应量(Cohens d) |
| --alpha | 浮点数 | 0.05 | 否 | I类错误率 |
| --power | 浮点数 | 0.80 | 否 | 目标统计效能 |
| --interim-looks | 整数 | 1 | 否 | 中期分析次数 |
| --spending-function | 字符串 | obrien_fleming | 否 | Alpha消耗函数 |
| --reestimate-method | 字符串 | promising_zone | 否 | 样本量重新估计方法 |
| --output | 字符串 | results.json | 否 | 输出文件路径 |
| --visualize | 标志 | False | 否 | 生成可视化图表 |
| --optimize | 标志 | False | 否 | 搜索最优设计参数 |
高级用法
bash
带可视化的完整自适应设计
python scripts/main.py \
--design adaptive_reestimate \
--n-simulations 50000 \
--sample-size 250 \
--effect-size 0.35 \
--interim-looks 2 \
--spending-function obrien_fleming \
--visualize \
--output adaptive_results.json
设计类型
| 设计类型 | 说明 | 适用场景 |
|---|
| 组序贯设计 | 固定中期分析次数,带停止边界 | 标准自适应试验 |
| 自适应重新估计 |
基于中期数据调整样本量 | 效应量不确定 |
|
淘汰劣势组 | 多臂试验中淘汰劣势组 | II期剂量选择 |
消耗函数
| 函数 | 特点 | 早期边界 |
|---|
| OBrien-Fleming | 早期保守 | 早期高Z值 |
| Pocock |
早期激进 | 全程较低Z值 |
|
幂族函数 | 适中(ρ=3) | 平衡方法 |
输出示例
json
{
design_config: {
designtype: adaptivereestimate,
samplesizeper_arm: 200,
effect_size: 0.3,
alpha: 0.05,
target_power: 0.8
},
simulation_results: {
power: 0.8234,
typeierror: 0.0481,
expectedsamplesize: 385.2,
earlystoprate: {
efficacy: 0.1523,
futility: 0.0841
}
}
}
技术难度:高
⚠️ AI自主验收状态:需人工检查
此技能需要:
- - Python 3.8+ 环境
- NumPy、SciPy和Matplotlib包
- 临床试验统计学知识
依赖项
bash
pip install -r requirements.txt
环境要求
numpy>=1.20.0
scipy>=1.7.0
matplotlib>=3.4.0
风险评估
| 风险指标 | 评估 | 等级 |
|---|
| 代码执行 | 带数学计算的Python脚本 | 中等 |
| 网络访问 |
无网络访问 | 低 |
| 文件系统访问 | 写入模拟结果 | 低 |
| 指令篡改 | 统计参数可能影响结果 | 中等 |
| 数据泄露 | 无敏感数据泄露 | 低 |
安全检查清单
- - [x] 无硬编码凭证或API密钥
- [x] 无未经授权的文件系统访问
- [x] 输出不泄露敏感信息
- [x] 输入参数已验证
- [x] 错误信息已清理
- [x] 依赖项已审计
前置条件
bash
pip install -r requirements.txt
python scripts/main.py --help
评估标准
成功指标
- - [ ] 模拟运行无错误
- [ ] I类错误控制在名义水平
- [ ] 效能估计准确
- [ ] 可视化正确生成
测试用例
- 1. 基础模拟:默认参数 → 有效结果
- 不同设计:所有设计类型 → 适当行为
- 优化模式:--optimize标志 → 找到最优参数
- 可视化:--visualize标志 → 生成图表
生命周期状态
- - 当前阶段:草稿
- 下次审核日期:2026-03-15
- 已知问题:numpy数组的类型检查警告
- 计划改进:
- 贝叶斯自适应设计
- 多臂多阶段(MAMS)支持
- 增强可视化选项
参考资料
位于 references/ 目录:
- - 自适应设计统计理论
- 监管指导文件
- Alpha消耗函数文献
- 样本量重新估计方法
局限性
- - 统计复杂性:需要生物统计学专业知识
- 模拟时间:大规模模拟可能需要数小时
- 简化模型:无法涵盖所有现实复杂性
- 监管咨询:结果需与监管机构验证
⚠️ 免责声明:本工具仅提供用于研究和规划的模拟结果。所有临床试验设计在实施前应由合格的生物统计学家和监管专家审核。