Skip to content
svgsequential-boundary

Group-sequential boundaries

At each interim look, has the test statistic crossed the efficacy or futility boundary?

Demo data · seed 20261101 · 13 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read the black path as the test statistic at each look.
  2. Crossing the upper boundary means stop for efficacy; the lower, for futility.
  3. Boundaries are wider early because evidence is thin.
  1. Callout 1: The path crosses the efficacy boundary here.
  2. Callout 2: Efficacy region.
  3. Callout 3: Futility region.

Watch out

  • Estimates at early stopping tend to be too large: use the adjusted estimate.

Defaults

No settings: the chart draws one way.

Pinned in the code

  • Draws the run's numbers as given (computed by the Python/R engine); the chart computes nothing statistical.
  • Series named like efficacy/upper/lower are boundaries (a level holding both signs is split into upper and lower for two-sided designs); futility is dashed; the observed path is drawn on top.
  • A crossing is the first observed look with z at or above the efficacy boundary interpolated at that information; the engine's spending function and decision are authoritative.
# Group-sequential boundaries — Codesplash Chart Lab (recipe "sequential-boundary")
# controls: defaults
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

try:
    import codesplash as cs  # optional: the app's chart theme
except ImportError:
    cs = None
if cs:
    cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]

df = pd.read_csv("sequential-boundary-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["series"] = pd.Categorical(df["series"].astype("string"), categories=["efficacy (O'Brien–Fleming)", "futility (non-binding)", "observed z"])

def levels_of(s):
    """Declared level order (categoricals), else order of first appearance."""
    if isinstance(s.dtype, pd.CategoricalDtype):
        return [v for v in s.cat.categories if (s == v).any()]
    return list(dict.fromkeys(s.dropna().astype(str)))
I = "information fraction"
Z = "z statistic"
B = "series"
groups = levels_of(df[B]) if B else [None]
series = []
for name in groups:
    d = df if name is None else df[df[B].astype(str) == str(name)]
    series.append((name if name is not None else "", d.dropna(subset=[I]).sort_values(I)))
fig, ax = plt.subplots(figsize=(8, 4.5))
ax.axhline(0, color="grey", linewidth=0.8)
for name, d in series:
    low = str(name).lower()
    kind = "futility" if "futil" in low else "observed" if any(w in low for w in ("observ", "path", "stat")) else "efficacy"
    col = {"efficacy": PALETTE[0], "futility": PALETTE[1], "observed": "black"}[kind]
    for part in ([d[d[Z] >= 0], d[d[Z] < 0]] if kind != "observed" and (d[Z] < 0).any() and (d[Z] > 0).any() else [d]):
        ax.plot(part[I], part[Z], marker="o", ms=4 if kind != "observed" else 6, color=col, linestyle="--" if kind == "futility" else "-", linewidth=2 if kind == "observed" else 1.5)
    ax.plot([], [], color=col, label=name)
ax.set_xlabel(I)
ax.set_ylabel(Z)
ax.legend(fontsize=8)
plt.show()

Needs pandas, numpy, matplotlib · reads sequential-boundary-demo.csv · app theme from the optional codesplash helper