clinical-trialslisted
Install: claude install-skill choxos/BiostatAgent
# Clinical Trials Statistical Methods
## Overview
Comprehensive clinical trial design and analysis methods in R covering sample size calculation, randomization, interim analyses, multiplicity adjustment, and regulatory-compliant statistical methods.
## Sample Size Calculation
### Two-Group Comparisons
```r
library(pwr)
# Two-sample t-test
pwr.t.test(
d = 0.5, # Cohen's d effect size
sig.level = 0.05,
power = 0.80,
type = "two.sample",
alternative = "two.sided"
)
# Proportions (chi-square)
pwr.2p.test(
h = ES.h(p1 = 0.6, p2 = 0.4), # Cohen's h
sig.level = 0.05,
power = 0.80
)
# Two proportions (unequal groups)
pwr.2p2n.test(
h = ES.h(p1 = 0.6, p2 = 0.4),
n1 = 100,
sig.level = 0.05
)
```
### Survival Endpoints
```r
library(gsDesign)
# Log-rank test sample size
nSurv(
lambda1 = log(2)/12, # Control median = 12 months
lambda2 = log(2)/18, # Treatment median = 18 months (HR = 0.67)
Ts = 24, # Study duration
Tr = 12, # Accrual duration
alpha = 0.025, # One-sided
beta = 0.20, # 80% power
ratio = 1 # 1:1 randomization
)
# Using rpact
library(rpact)
getSampleSizeSurvival(
hazardRatio = 0.67,
lambda1 = log(2)/12,
accrualTime = 12,
followUpTime = 12,
alpha = 0.025,
beta = 0.20,
allocationRatioPlanned = 1
)
```
### Non-Inferiority Trials
```r
library(TrialSize)
# Non-inferiority for proportions
TwoSampleProportion.NIS(
p = 0.80, # Expected propo