BA/B tests · experiment.sequential
Sequential monitoring — group-sequential boundaries and always-valid p-values
When may an A/B test stop early, and what do the interim looks say so far?
Error-spending group-sequential design for interim looks at an A/B test — Lan–DeMets O'Brien–Fleming or Pocock, Hwang–Shih–DeCani, power family or Haybittle–Peto efficacy bounds, optional non-binding futility bounds — with the sample-size inflation, expected sample size and stopping probabilities, the decision at each observed look, and mixture-SPRT always-valid p-values and intervals for continuous monitoring. Classical boundary families — Pocock's constant bounds, O'Brien–Fleming's c/√t and the Wang–Tsiatis Δ family — are solved jointly for the overall α.
A real result
Example “Obf two sided”, recorded in both engines. In the app, “Try this example” loads it into Analyze.
3 looks, inflation 1.0128, final bound z = 1.993.
- Information inflation
- 1.013
- Expected size under H1 (fraction of fixed)
- 0.8656
- Expected size under H0 (fraction of fixed)
- 1.009
- Final efficacy z
- 1.993
Plots
View data
| Bound | Information fraction | z |
|---|---|---|
| efficacy | 0.3333 | 3.710 |
| efficacy | 0.3333 | −3.710 |
| efficacy | 0.6667 | 2.511 |
| efficacy | 0.6667 | −2.511 |
| efficacy | 1 | 1.993 |
| efficacy | 1 | −1.993 |
Boundaries by look
| Look | Information | Efficacy z | Nominal p | α spent (cumulative) | P(stop for efficacy | H0) | P(stop for efficacy | H1) |
|---|---|---|---|---|---|---|
| 1 | 33.3% | 3.710 | < .001 | 0.0002 | 0.0002 | 0.0186 |
| 2 | 66.7% | 2.511 | .012 | 0.0121 | 0.0119 | 0.3988 |
| 3 | 100.0% | 1.993 | .046 | 0.0500 | 0.0379 | 0.3826 |
- Bounds on the z scale of the treatment − control difference; information fractions are shares of the maximum information (≈ units).
- Non-binding futility: the efficacy bounds assume the trial may continue past a futility bound, so stopping for futility never inflates α.
- Always-valid p-values stay valid under continuous peeking; they are larger than fixed-horizon p-values.
3 looks, inflation 1.0128, final bound z = 1.993.
- Information inflation
- 1.013
- Expected size under H1 (fraction of fixed)
- 0.8656
- Expected size under H0 (fraction of fixed)
- 1.009
- Final efficacy z
- 1.993
To keep this page light, the plots are shown once, under the R tab.
Boundaries by look
| Look | Information | Efficacy z | Nominal p | α spent (cumulative) | P(stop for efficacy | H0) | P(stop for efficacy | H1) |
|---|---|---|---|---|---|---|
| 1 | 33.3% | 3.710 | < .001 | 0.0002 | 0.0002 | 0.0186 |
| 2 | 66.7% | 2.511 | .012 | 0.0121 | 0.0119 | 0.3988 |
| 3 | 100.0% | 1.993 | .046 | 0.0500 | 0.0379 | 0.3826 |
- Bounds on the z scale of the treatment − control difference; information fractions are shares of the maximum information (≈ units).
- Non-binding futility: the efficacy bounds assume the trial may continue past a futility bound, so stopping for futility never inflates α.
- Always-valid p-values stay valid under continuous peeking; they are larger than fixed-horizon p-values.
Do it in CodeSplash Run it on your own data, in Python or R, with the code to prove it.
Worked examples in the app
- Obf two sidedNo data needed
- Pocock one sided futilityNo data needed
- Hsd uneven timingNo data needed
- Haybittle peto msprtNo data needed
- Pocock classic guideNo data needed
- Obf classic guideNo data needed
- Wang tsiatis guideNo data needed
- Wang tsiatis unevenNo data needed
In the guides
Tests from the statistics guide this method runs
Where it sits in the decision guides
- Multiple comparisons · Statistics Guide · Additional considerations
- A/B testing (hypothesis testing) · DS & ML Decision Guide · Optimize / decide
Choices you make
hypothesis
- Looks (including the final analysis)default 3
Number of planned analyses, including the final one.
- Information fractions of the looksdefault
Empty = equally spaced (1/K, 2/K, …, 1). The last look is always 1.
- Significance level (α)default 0.05
The false-alarm rate you accept: the chance of a significant result when there is truly no effect. 0.05 is conventional.
- Power (1 − β)default 0.8
Chance of stopping for efficacy if the effect is real. Sequential designs need slightly more data than fixed ones.
- Testdefault two-sided
Which direction counts as evidence. Keep two-sided unless you fixed the direction before seeing the data.
- Two-sided (symmetric bounds, α/2 each side)(default) — Sets symmetric bounds with α/2 on each side; the usual choice, and it can also stop for harm.
- One-sided (efficacy in the expected direction) — Sets bounds for efficacy in the expected direction only; needs less data, but won't stop for harm.
- Efficacy boundsdefault obf
How α is spent across looks. O'Brien–Fleming is strict early and close to a fixed test at the end.
- O'Brien–Fleming-like (Lan–DeMets) — conservative early(default) — Spends almost no α early; the final bound stays close to the fixed-sample one. Looks may move without breaking α.
- Pocock-like (Lan–DeMets) — equal-ish bounds — Spends α evenly, so early stopping is easier but the final bound is much stricter than 1.96.
- Hwang–Shih–DeCani (γ) — A one-parameter family: γ = −4 behaves like O'Brien–Fleming, γ = 1 like Pocock.
- Power family α·tᵖ (Kim–DeMets) — Spends α·tᵖ by information fraction t; ρ = 3 is close to O'Brien–Fleming, ρ = 1 to Pocock.
- Haybittle–Peto (z = 3 at interim looks) — z = 3 at every interim look and almost the full α at the end; simple and conservative.
- Pocock (classical constant bounds) — The same z bound at every look, solved jointly so the overall α holds; easy to stop early, costly at the end.
- O'Brien–Fleming (classical c / √t) — Very strict early, close to the fixed-sample bound at the end; the usual choice when early stopping should need overwhelming evidence.
- Wang–Tsiatis (Δ family) — Bounds c·t^(Δ − ½): Δ = 0 is O'Brien–Fleming, Δ = ½ Pocock; values in between trade early against late evidence.
- Spending parameter (γ for HSD, ρ for the power family)default -4
Shape parameter for the Hwang–Shih–DeCani (γ) or power-family (ρ) spending function.
- Wang–Tsiatis shape Δdefault 0.25
0 = O'Brien–Fleming shape, 0.5 = Pocock shape; the guide's example uses 0.25.
options
- Futility boundsdefault none
Also stop early when the effect looks unlikely to reach significance (non-binding: you may continue).
- None(default) — Stops only for efficacy or at the end; pick it when you'd run to the end anyway if the effect looks weak.
- Non-binding β-spending (one-sided tests) — Adds β-spending futility bounds you may ignore; one-sided tests only, and the type I error holds either way.
- Futility spendingdefault hsd
Spending function for the futility bounds.
- Hwang–Shih–DeCani (γ)(default) — Spends β along the Hwang–Shih–DeCani curve; γ sets how early it goes.
- O'Brien–Fleming-like — Spends little β early, so stopping early for futility is rare.
- Pocock-like — Spends β evenly across looks, so early futility stops come easier.
- Power family — Spends β as a power of the information used; the exponent sets the pace.
- Futility spending parameterdefault -2
Shape parameter for the futility spending function.
- Fixed-design units per arm (from the plan)default —
Scales the design: the maximum and per-look units per arm.
- Observed z at completed looksdefault
Treatment − control z statistics at the looks so far, in order.
statistics
- Always-valid: observed differences at each lookdefault
Observed differences at each look so far, for always-valid p-values.
- Always-valid: standard errors of those differencesdefault
Standard errors of those differences.
- Always-valid: mixing SD τdefault —
Mixing SD for always-valid p-values: about the effect size you expect. Empty uses a default.
What it reports
- inflation
- A plan for how much of the false-positive budget each interim look may use.
- i_max
- A plan for how much of the false-positive budget each interim look may use.
- i_fix
- A plan for how much of the false-positive budget each interim look may use.
- en0
- The expected number of observations a sequential test uses before it stops, at a given true parameter.
- en1
- The expected number of observations a sequential test uses before it stops, at a given true parameter.
- power_check
- Power the final group-sequential design achieves, recomputed as a check that it meets the target power.
- type1
- Rejecting H₀ when it is actually true — a false alarm.
- looks
- Planned interim looks at accumulating data with boundaries that keep the overall false-positive rate at α.
- alpha
- The α this run used for its decisions and boundaries.
- inflation_pct
- Extra share of the fixed-design sample size the group-sequential plan needs at most (0.05 = 5% more).
- upper_final
- z-value the test statistic must cross at the last look to declare an effect.
Per group, level or term: decision_last, upper[<look>]
Python and R
Python and R agree to 6 decimals (relative tolerance 1e-9). Python uses numpy, scipy, codesplash; R uses stats, codesplashr.
Default traps between the two languages
- Bounds come from Brent root finding (brentq ↔ uniroot, tol 1e-12) over identical Jennison–Turnbull grids (r = 18) — the same grids as gsDesign, which they match to its own tolerance (≤ 1e-7).
- Classical Pocock / O'Brien–Fleming / Wang–Tsiatis bounds solve one constant c for the joint H0 crossing probability; they match gsDesign(sfu = "Pocock" | "OF" | "WT") to ≤ 2e-7 (e.g. K = 3, two-sided α = 0.05: Pocock 2.289478, O'Brien–Fleming 3.471091 / 2.454432 / 2.004036).
The exact script CodeSplash ran for example “Obf two sided” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Sequential monitoring — group-sequential boundaries and always-valid p-values
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method experiment.sequential 1.1.0 · spec 89c871e867a1c9b9
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import math
from scipy.special import ndtr, ndtri
import codesplash as cs
from codesplash.experiment import analyze as xa # mixture SPRT (twin of R cs_exp_msprt)
from codesplash.experiment import sequential as gs # error-spending bounds (twin of R cs_exp_gs_*)
# %% Inputs
looks = int(3)
timing = [] # information fractions (empty = equally spaced)
alpha = 0.05
beta = 1.0 - 0.8
two_sided = "two-sided" == "two-sided"
spending = "obf" # obf | pocock | hsd | power | hp | pocock_classic | obf_classic | wt
param = 0.25 if spending == "wt" else -4 # Δ for Wang–Tsiatis
futility = "none" if not two_sided else "none"
fkind = "hsd"
fparam = -2
n_fixed = None
observed = []
m_diff = []
m_se = []
m_tau = None
warnings = []
if spending == "power" and param <= 0:
raise ValueError("The power family needs ρ > 0.")
if not timing:
timing = [(k + 1) / looks for k in range(looks)]
else:
timing = sorted(float(t) for t in timing)[:looks]
if len(timing) < looks:
raise ValueError(f"Give {looks} information fractions (or none for equal spacing).")
timing[-1] = 1.0
if any(b <= a for a, b in zip(timing, timing[1:])):
raise ValueError("Information fractions must increase.")
if "none" == "nonbinding" and two_sided:
warnings.append("Futility bounds are only offered for one-sided designs; none were added.")
# Equivalent idiom (R): gsDesign::gsDesign(k, test.type = 1 | 2 | 4, alpha, beta, timing, sfu = sfLDOF, sfl = sfHSD).
# %% Design
d = gs.design(timing, alpha, beta, two_sided, spending, param, futility, fkind, fparam)
upper, lower = d["upper"], d["lower"]
# %% Observed looks
decisions = []
for k, z in enumerate(observed[:looks]):
if (abs(z) if two_sided else z) >= upper[k]:
decisions.append("stop: efficacy")
elif futility == "nonbinding" and z <= lower[k] and k < looks - 1:
decisions.append("stop: futility (non-binding)")
elif k == looks - 1:
decisions.append("final: not significant")
else:
decisions.append("continue")
if len(observed) > looks:
warnings.append(f"Only the first {looks} observed z values were used.")
# %% Always-valid monitoring (mixture SPRT)
m_p, m_lo, m_hi = [], [], []
tau_used = None
if m_diff:
if len(m_se) != len(m_diff):
raise ValueError("Give one standard error per observed difference.")
tau_used = m_tau if m_tau else (float(ndtri(1.0 - alpha / 2.0)) + float(ndtri(1.0 - beta))) * m_se[-1]
m_p, m_lo, m_hi = xa.msprt(m_diff, [s * s for s in m_se], tau_used, alpha)
# %% Result
rows = []
for k, t in enumerate(timing):
row = {
"look": k + 1, "t": t, "upper": upper[k],
"lower": (lower[k] if math.isfinite(lower[k]) else None),
"nominal_p": float(1.0 - ndtr(upper[k])) * (2.0 if two_sided else 1.0),
"spent": d["alpha_spent"][k] * (2.0 if two_sided else 1.0),
"cross_h0": d["pu0"][k] * (2.0 if two_sided else 1.0), "cross_h1": d["pu1"][k],
}
if n_fixed is not None:
row["n"] = int(math.ceil(n_fixed * d["inflation"] * t - 1e-9))
if k < len(decisions):
row["z"] = observed[k]
row["decision"] = decisions[k]
rows.append(row)
columns = [
{"key": "look", "label": "Look", "type": "integer"}, {"key": "t", "label": "Information", "type": "percent"},
*([{"key": "n", "label": "Units per arm", "type": "integer"}] if n_fixed is not None else []),
{"key": "upper", "label": "Efficacy z", "type": "number"},
*([{"key": "lower", "label": "Futility z", "type": "number"}] if futility == "nonbinding" else []),
{"key": "nominal_p", "label": "Nominal p", "type": "pvalue"}, {"key": "spent", "label": "α spent (cumulative)", "type": "number"},
{"key": "cross_h0", "label": "P(stop for efficacy | H0)", "type": "number"}, {"key": "cross_h1", "label": "P(stop for efficacy | H1)", "type": "number"},
*([{"key": "z", "label": "Observed z", "type": "number"}, {"key": "decision", "label": "Decision", "type": "string"}] if decisions else []),
]
tables = [{"key": "bounds", "title": "Boundaries by look", "columns": columns, "rows": rows}]
if m_p:
tables.append({
"key": "msprt", "title": f"Always-valid inference (mixture SPRT, τ = {tau_used:.4g})",
"columns": [{"key": "look", "label": "Look", "type": "integer"}, {"key": "diff", "label": "Difference", "type": "number"},
{"key": "p", "label": "Always-valid p", "type": "pvalue"}, {"key": "low", "label": "Lower", "type": "number"},
{"key": "high", "label": "Upper", "type": "number"}],
"rows": [{"look": i + 1, "diff": m_diff[i], "p": m_p[i], "low": m_lo[i], "high": m_hi[i]} for i in range(len(m_p))],
})
bx, bz, bl = [], [], []
for k, t in enumerate(timing):
bx.append(t); bz.append(upper[k]); bl.append("efficacy")
if two_sided:
bx.append(t); bz.append(-upper[k]); bl.append("efficacy") # one level, both signs: drawn as upper + lower lines
if futility == "nonbinding":
bx.append(t); bz.append(lower[k]); bl.append("futility")
for k, z in enumerate(observed[:looks]):
bx.append(timing[k]); bz.append(z); bl.append("observed")
values = {
"looks": looks, "alpha": alpha, "inflation": d["inflation"], "inflation_pct": d["inflation"] - 1.0, "i_max": d["i_max"],
"i_fix": d["i_fix"], "en0": d["en0"], "en1": d["en1"], "power_check": d["power"], "type1": d["type1"],
"upper_final": upper[-1], "n_max": int(math.ceil(n_fixed * d["inflation"] - 1e-9)) if n_fixed is not None else None,
"decision_last": decisions[-1] if decisions else None, "tau": tau_used,
}
for k in range(looks):
values[f"upper[{k + 1}]"] = upper[k]
values[f"lower[{k + 1}]"] = lower[k] if math.isfinite(lower[k]) else None
values[f"spent[{k + 1}]"] = d["alpha_spent"][k]
values[f"cross_h0[{k + 1}]"] = d["pu0"][k]
values[f"cross_h1[{k + 1}]"] = d["pu1"][k]
for i in range(len(m_p)):
values[f"msprt_p[{i + 1}]"] = m_p[i]
values[f"msprt_low[{i + 1}]"] = m_lo[i]
values[f"msprt_high[{i + 1}]"] = m_hi[i]
cs.publish({
"method": "experiment.sequential",
"methodVersion": "1.1.0",
"title": "Sequential monitoring plan",
"engine": cs.engine_info("scipy"),
"summary": f"{looks} looks, inflation {d['inflation']:.4f}, final bound z = {upper[-1]:.3f}.",
"statistics": [
{"key": "inflation", "label": "Information inflation", "value": d["inflation"]},
{"key": "en1", "label": "Expected size under H1 (fraction of fixed)", "value": d["en1"]},
{"key": "en0", "label": "Expected size under H0 (fraction of fixed)", "value": d["en0"]},
{"key": "upper_final", "label": "Final efficacy z", "value": upper[-1]},
],
"tables": tables,
"warnings": warnings,
"notes": [
"Bounds on the z scale of the treatment − control difference; information fractions are shares of the maximum information (≈ units).",
"Non-binding futility: the efficacy bounds assume the trial may continue past a futility bound, so stopping for futility never inflates α.",
"Always-valid p-values stay valid under continuous peeking; they are larger than fixed-horizon p-values.",
],
"charts": [cs.chart(
"boundaries", "sequential-boundary", "Stopping boundaries",
{"information": cs.col("Information fraction", bx), "z": cs.col("z", bz), "bound": cs.col("Bound", bl)},
)],
"values": values,
})
The exact script CodeSplash ran for example “Obf two sided” · R version 4.5.1 (2025-06-13)
# Sequential monitoring — group-sequential boundaries and always-valid p-values
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method experiment.sequential 1.1.0 · spec 89c871e867a1c9b9
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr) # error-spending bounds cs_exp_gs_* and cs_exp_msprt (twins of codesplash.experiment)
# %% Inputs
looks <- as.integer(3)
timing <- c() # information fractions (empty = equally spaced)
alpha <- 0.05
beta <- 1 - 0.8
two_sided <- "two-sided" == "two-sided"
spending <- "obf" # obf | pocock | hsd | power | hp | pocock_classic | obf_classic | wt
param <- if (spending == "wt") 0.25 else -4 # Delta for Wang-Tsiatis
futility <- if (two_sided) "none" else "none"
fkind <- "hsd"
fparam <- -2
n_fixed <- NULL
observed <- as.numeric(unlist(c()))
m_diff <- as.numeric(unlist(c()))
m_se <- as.numeric(unlist(c()))
m_tau <- NULL
warnings <- list()
if (spending == "power" && param <= 0) stop("The power family needs rho > 0.")
timing <- as.numeric(unlist(timing))
if (!length(timing)) {
timing <- (seq_len(looks)) / looks
} else {
timing <- sort(timing)[seq_len(min(length(timing), looks))]
if (length(timing) < looks) stop(sprintf("Give %d information fractions (or none for equal spacing).", looks))
timing[looks] <- 1
}
if (looks > 1 && any(diff(timing) <= 0)) stop("Information fractions must increase.")
if ("none" == "nonbinding" && two_sided) warnings <- c(warnings, "Futility bounds are only offered for one-sided designs; none were added.")
# Equivalent idiom: gsDesign::gsDesign(k = looks, test.type = if (two_sided) 2 else 1, alpha = alpha / 2, beta = beta, timing = timing, sfu = sfLDOF)
# %% Design
d <- cs_exp_gs_design(timing, alpha, beta, two_sided, spending, param, futility, fkind, fparam)
upper <- d$upper
lower <- d$lower
# %% Observed looks
decisions <- character(0)
for (k in seq_len(min(length(observed), looks))) {
z <- observed[k]
decisions[k] <- if ((if (two_sided) abs(z) else z) >= upper[k]) "stop: efficacy"
else if (futility == "nonbinding" && z <= lower[k] && k < looks) "stop: futility (non-binding)"
else if (k == looks) "final: not significant"
else "continue"
}
if (length(observed) > looks) warnings <- c(warnings, sprintf("Only the first %d observed z values were used.", looks))
# %% Always-valid monitoring (mixture SPRT)
ms <- NULL
tau_used <- NULL
if (length(m_diff)) {
if (length(m_se) != length(m_diff)) stop("Give one standard error per observed difference.")
tau_used <- if (!is.null(m_tau) && m_tau > 0) m_tau else (stats::qnorm(1 - alpha / 2) + stats::qnorm(1 - beta)) * m_se[length(m_se)]
ms <- cs_exp_msprt(m_diff, m_se^2, tau_used, alpha)
}
# %% Result
mult <- if (two_sided) 2 else 1
rows <- lapply(seq_len(looks), function(k) {
row <- list(look = k, t = timing[k], upper = upper[k], lower = if (is.finite(lower[k])) lower[k] else NULL,
nominal_p = (1 - stats::pnorm(upper[k])) * mult, spent = d$alpha_spent[k] * mult,
cross_h0 = d$pu0[k] * mult, cross_h1 = d$pu1[k])
if (!is.null(n_fixed)) row$n <- as.integer(ceiling(n_fixed * d$inflation * timing[k] - 1e-9))
if (k <= length(decisions)) {
row$z <- observed[k]
row$decision <- decisions[k]
}
row
})
columns <- c(
list(list(key = "look", label = "Look", type = "integer"), list(key = "t", label = "Information", type = "percent")),
if (!is.null(n_fixed)) list(list(key = "n", label = "Units per arm", type = "integer")),
list(list(key = "upper", label = "Efficacy z", type = "number")),
if (futility == "nonbinding") list(list(key = "lower", label = "Futility z", type = "number")),
list(list(key = "nominal_p", label = "Nominal p", type = "pvalue"), list(key = "spent", label = "α spent (cumulative)", type = "number"),
list(key = "cross_h0", label = "P(stop for efficacy | H0)", type = "number"), list(key = "cross_h1", label = "P(stop for efficacy | H1)", type = "number")),
if (length(decisions)) list(list(key = "z", label = "Observed z", type = "number"), list(key = "decision", label = "Decision", type = "string"))
)
tables <- list(list(key = "bounds", title = "Boundaries by look", columns = columns, rows = rows))
if (!is.null(ms)) {
tables <- c(tables, list(list(
key = "msprt", title = sprintf("Always-valid inference (mixture SPRT, τ = %.4g)", tau_used),
columns = list(list(key = "look", label = "Look", type = "integer"), list(key = "diff", label = "Difference", type = "number"),
list(key = "p", label = "Always-valid p", type = "pvalue"), list(key = "low", label = "Lower", type = "number"),
list(key = "high", label = "Upper", type = "number")),
rows = lapply(seq_along(ms$p), function(i) list(look = i, diff = m_diff[i], p = ms$p[i], low = ms$low[i], high = ms$high[i]))
)))
}
bx <- bz <- numeric(0)
bl <- character(0)
for (k in seq_len(looks)) {
bx <- c(bx, timing[k]); bz <- c(bz, upper[k]); bl <- c(bl, "efficacy")
if (two_sided) { bx <- c(bx, timing[k]); bz <- c(bz, -upper[k]); bl <- c(bl, "efficacy") }
if (futility == "nonbinding") { bx <- c(bx, timing[k]); bz <- c(bz, lower[k]); bl <- c(bl, "futility") }
}
for (k in seq_len(min(length(observed), looks))) { bx <- c(bx, timing[k]); bz <- c(bz, observed[k]); bl <- c(bl, "observed") }
values <- list(
looks = looks, alpha = alpha, inflation = d$inflation, inflation_pct = d$inflation - 1, i_max = d$i_max,
i_fix = d$i_fix, en0 = d$en0, en1 = d$en1, power_check = d$power, type1 = d$type1,
upper_final = upper[looks], n_max = if (is.null(n_fixed)) NA else as.integer(ceiling(n_fixed * d$inflation - 1e-9)),
decision_last = if (length(decisions)) decisions[length(decisions)] else NA, tau = if (is.null(tau_used)) NA else tau_used
)
for (k in seq_len(looks)) {
values[[sprintf("upper[%d]", k)]] <- upper[k]
values[[sprintf("lower[%d]", k)]] <- if (is.finite(lower[k])) lower[k] else NA
values[[sprintf("spent[%d]", k)]] <- d$alpha_spent[k]
values[[sprintf("cross_h0[%d]", k)]] <- d$pu0[k]
values[[sprintf("cross_h1[%d]", k)]] <- d$pu1[k]
}
if (!is.null(ms)) for (i in seq_along(ms$p)) {
values[[sprintf("msprt_p[%d]", i)]] <- ms$p[i]
values[[sprintf("msprt_low[%d]", i)]] <- ms$low[i]
values[[sprintf("msprt_high[%d]", i)]] <- ms$high[i]
}
cs_publish(list(
method = "experiment.sequential",
methodVersion = "1.1.0",
title = "Sequential monitoring plan",
engine = cs_engine_info("stats"),
summary = sprintf("%d looks, inflation %.4f, final bound z = %.3f.", looks, d$inflation, upper[looks]),
statistics = list(
list(key = "inflation", label = "Information inflation", value = d$inflation),
list(key = "en1", label = "Expected size under H1 (fraction of fixed)", value = d$en1),
list(key = "en0", label = "Expected size under H0 (fraction of fixed)", value = d$en0),
list(key = "upper_final", label = "Final efficacy z", value = upper[looks])
),
tables = tables,
warnings = warnings,
notes = c("Bounds on the z scale of the treatment − control difference; information fractions are shares of the maximum information (≈ units).",
"Non-binding futility: the efficacy bounds assume the trial may continue past a futility bound, so stopping for futility never inflates α.",
"Always-valid p-values stay valid under continuous peeking; they are larger than fixed-horizon p-values."),
charts = list(cs_chart(
"boundaries", "sequential-boundary", "Stopping boundaries",
list(information = cs_col("Information fraction", bx), z = cs_col("z", bz), bound = cs_col("Bound", bl))
)),
values = values
))
Sources
- Jennison, C., & Turnbull, B. W. (2000). Group sequential methods with applications to clinical trials. Chapman & Hall/CRC (ch. 7 and 19).
- Lan, K. K. G., & DeMets, D. L. (1983). Discrete sequential boundaries for clinical trials. Biometrika, 70, 659–663.
- Pocock, S. J. (1977). Group sequential methods in the design and analysis of clinical trials. Biometrika, 64, 191–199.
- O'Brien, P. C., & Fleming, T. R. (1979). A multiple testing procedure for clinical trials. Biometrics, 35, 549–556.
- Wang, S. K., & Tsiatis, A. A. (1987). Approximately optimal one-parameter boundaries for group sequential trials. Biometrics, 43, 193–199.
- Hwang, I. K., Shih, W. J., & DeCani, J. S. (1990). Group sequential designs using a family of type I error probability spending functions. Statistics in Medicine, 9, 1439–1445.
- Anderson, K. M. (2024). gsDesign: Group Sequential Design. R package.
- Johari, R., Koomen, P., Pekelis, L., & Walsh, D. (2017). Peeking at A/B tests: Why it matters, and what to do about it. KDD '17.
From the CodeSplash method registry · experiment.sequential v1.1.0.