Skip to content
svgspec-curve

Specification curve

Does the conclusion survive every reasonable way of specifying the analysis?

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

How to read it

  1. Read the top panel as estimates across every specification, ranked by size.
  2. Read the dots below for which choices each specification uses.
  3. Look for choices that line up at one end: they drive the result.
  1. Callout 1: Estimates sorted by size.
  2. Callout 2: The choices behind each specification.
  3. Callout 3: The median and the share with the same sign.

Watch out

  • The specifications aren't independent, and the set you list shapes the picture.

Defaults

Null value
0
The value that means no effect.
Range -1,000,000,000 to 1,000,000,000, step 0.1

Pinned in the code

  • Draws the run's numbers as given (computed by the Python/R engine); the chart computes nothing statistical.
  • Input has one row per specification × choice dimension; specifications are drawn in the order of `spec` (the engine ranks them by estimate).
  • The summary counts significant specifications and those sharing the median's sign; Simonsohn et al.'s permutation inference is reported by the engine when run.
# Specification curve — Codesplash Chart Lab (recipe "spec-curve")
# controls: null=0
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("spec-curve-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["dimension"] = pd.Categorical(df["dimension"].astype("string"), categories=["covariates", "outliers", "outcome", "sample"])

SPEC = "specification"
E = "effect (SD)"
LO = "ci_low"
HI = "ci_high"
SIG = "significant"
DIM = "dimension"
OPT = "option"
NULL = 0
specs = df.drop_duplicates(SPEC).sort_values(SPEC)
rows = df[[DIM, OPT]].astype(str).drop_duplicates().values.tolist()
fig, (ax, bx) = plt.subplots(2, 1, figsize=(8, 6), sharex=True, gridspec_kw=dict(height_ratios=[2, 1.3]))
col = np.where(specs[SIG].astype(bool), PALETTE[0], "grey")
if LO and HI: ax.vlines(specs[SPEC], specs[LO], specs[HI], colors=col, alpha=0.35)
ax.scatter(specs[SPEC], specs[E], c=col, s=12)
ax.axhline(NULL, color="grey", linewidth=0.8)
ax.axhline(specs[E].median(), color=PALETTE[1], linestyle="--", linewidth=1)
ax.set_ylabel(E)
for k, (dim, opt) in enumerate(rows):
    used = df[(df[DIM].astype(str) == dim) & (df[OPT].astype(str) == opt)][SPEC]
    bx.scatter(used, [k] * len(used), color="black", s=6)
bx.set_yticks(range(len(rows)), [f"{d}: {o}" for d, o in rows], fontsize=7)
bx.invert_yaxis()
bx.set_xlabel("specifications, ranked by estimate")
plt.show()

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