# Group Sequential Methods

> Group sequential design methods for interim analyses, alpha spending, and futility stopping. Use when designing trials with interim looks or implementing spending functions.

- **Type:** Skill
- **Install:** `agentstack add skill-choxos-biostatagent-group-sequential-methods`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [choxos](https://agentstack.voostack.com/s/choxos)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [choxos](https://github.com/choxos)
- **Source:** https://github.com/choxos/BiostatAgent/tree/main/plugins/clinical-trial-simulation/skills/group-sequential-methods

## Install

```sh
agentstack add skill-choxos-biostatagent-group-sequential-methods
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Group Sequential Methods

## When to Use This Skill

- Designing group sequential trials with interim analyses
- Implementing alpha spending functions
- Setting futility stopping rules
- Calculating information fractions
- Using sim_gs_n() for GS simulations
- Integrating with gsDesign2 package

## Fundamental Concepts

### Group Sequential Design

A group sequential design allows for:
- **Early stopping for efficacy**: If treatment effect is larger than expected
- **Early stopping for futility**: If treatment effect is unlikely to reach significance
- **Reduced expected sample size**: When treatment effect is present

### Information Fraction

Information fraction at analysis k:
```
I_k / I_K = (events at analysis k) / (total planned events)
```

For time-to-event trials, information ≈ number of events.

### Type I Error Spending

The key constraint is that the design controls the overall Type I error at the planned alpha level. Spending functions define cumulative alpha spending over information time, and boundaries are derived using the joint distribution of sequential test statistics. They are not obtained by simply assigning independent nominal alpha levels to each look.

## Alpha Spending Functions

### O'Brien-Fleming (OBF)

**Properties:**
- Conservative at early analyses
- Nearly full alpha at final analysis
- Difficult to stop early
- Maintains nominal Type I error

**Formula:**
```
α*(t) = 2 - 2Φ(z_{α/2} / √t)
```

**When to Use:**
- Want maximum power at final analysis
- Early efficacy stopping unlikely
- Regulatory preference for conservative early bounds

### Pocock

**Properties:**
- Equal spending at each analysis
- Easier to stop early
- Inflated final alpha
- Lower power at final analysis

**Formula:**
```
α*(t) = α × log(1 + (e-1)t)
```

**When to Use:**
- Early stopping is a priority
- Treatment effect expected to be large
- Willing to sacrifice final analysis power

### Hwang-Shih-DeCani (HSD)

**Properties:**
- Flexible family indexed by γ
- γ = -4: Similar to OBF
- γ = 1: Similar to Pocock
- γ = 0: Linear (Pocock-like)

**Formula:**
```
α*(t) = α × (1 - e^{-γt}) / (1 - e^{-γ})
```

**When to Use:**
- Want flexibility between OBF and Pocock
- Customized spending pattern needed

### Spending Function Comparison

| Function | Early Spending | Final Power | Early Stopping |
|----------|---------------|-------------|----------------|
| OBF | Low | High | Difficult |
| Pocock | High | Lower | Easier |
| HSD(γ=-4) | Low | High | Difficult |
| HSD(γ=1) | High | Lower | Easier |

## Futility Boundaries

### Binding Futility

- If futility boundary crossed, trial MUST stop
- Affects Type I error calculation
- More powerful than non-binding

### Non-Binding Futility

- Crossing futility boundary is advisory
- Trial can continue at investigator discretion
- Conservative: assumes no early stopping for futility in Type I error

### Beta-Spending for Futility

Similar to alpha-spending, but for Type II error:
```
β*(t) = spending function × β
```

## simtrial GS Implementation

### create_cut() - Define Analysis Timing

```r
# Interim Analysis 1
ia1_cut  to_integer()

# Simulate with design object
sim_results 
  group_by(analysis) |>
  summarise(
    mean_events = mean(event),
    mean_z = mean(z),
    power = mean(z < qnorm(0.025)),  # One-sided
    .groups = "drop"
  )
```

## Best Practices

1. **Information Fraction**: Target evenly spaced (e.g., 50%, 100% or 33%, 67%, 100%)
2. **Alpha Spending**: OBF is default for most regulatory submissions
3. **Futility**: Use non-binding to preserve flexibility
4. **Validation**: Compare simulated power to gsDesign analytical results
5. **Documentation**: Record all boundary calculations for regulatory submission
6. **Parallelization**: Use `plan("multisession")` for large simulations

## Regulatory Considerations

- Pre-specify number and timing of interim analyses
- Pre-specify spending function and parameters
- Document stopping rules clearly in protocol
- Consider DSMB recommendations for unblinded reviews
- Maintain blinding for operational team

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [choxos](https://github.com/choxos)
- **Source:** [choxos/BiostatAgent](https://github.com/choxos/BiostatAgent)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-choxos-biostatagent-group-sequential-methods
- Seller: https://agentstack.voostack.com/s/choxos
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
