Skip to content

Show every road with a specification curve

Instead of choosing one analysis and defending it, run all the defensible ones and show how the estimate moves. Learn to read a specification curve, build a fair set, and report it.

Advanced ~13 min9 steps

What runs in CodeSplash

You will be able to

  • Read a specification curve and find the choices that drive a result
  • Decide which specifications are fair to include
  • Report a curve without turning it into a vote

Read first

01

Forty percent

Predict

Predict first

You rerun an analysis under 128 reasonable specifications. All the estimates have the same sign, and about 40% are significant. What do you conclude?

The effect is realThere's no effectThe answer depends on the choices, so find out which
Reveal

The answer depends on the choices, so find out which. Share significant isn't a verdict in either direction. The curve's value is in showing which choice moves the result.

02

Read the picture

Explore

A specification curveSpecification curveEvery defensible version of an analysis, sorted by estimate, with a panel showing the choices behind each one. has two panels. On top, one estimate per specification, sorted by size, with significant ones colored. Below, a dot for each choice that specification used.

Look down a column of dots. Then look across a row: if the dots for one choice bunch at one end, that choice is driving the result.

Specification curveDoes the conclusion survive every reasonable way of specifying the analysis?
View data
specificationeffect (SD)ci_lowci_highsignificantdimensionoption
10.0959−0.01580.2076falsecovariatesfull set
10.0959−0.01580.2076falseoutlierswinsorize 1%
10.0959−0.01580.2076falseoutcomelog
10.0959−0.01580.2076falsesamplecomplete cases
20.10000.01180.1882truecovariatesfull set
20.10000.01180.1882trueoutlierswinsorize 1%
20.10000.01180.1882trueoutcomelog
20.10000.01180.1882truesampleall
30.10300.01480.1912truecovariatesfull set
30.10300.01480.1912trueoutliersdrop |z| > 3
30.10300.01480.1912trueoutcomelog
30.10300.01480.1912truesampleall
40.1115−0.00020.2232falsecovariatesfull set
40.1115−0.00020.2232falseoutliersdrop |z| > 3
40.1115−0.00020.2232falseoutcomelog
40.1115−0.00020.2232falsesamplecomplete cases
50.12680.03860.2150truecovariatesfull set
50.12680.03860.2150trueoutlierskeep
50.12680.03860.2150trueoutcomelog
50.12680.03860.2150truesampleall
60.12980.01800.2415truecovariatesage + sex
60.12980.01800.2415trueoutliersdrop |z| > 3
60.12980.01800.2415trueoutcomelog
60.12980.01800.2415truesamplecomplete cases
70.14040.02860.2521truecovariatesfull set
70.14040.02860.2521trueoutlierskeep
70.14040.02860.2521trueoutcomelog
70.14040.02860.2521truesamplecomplete cases
80.14470.03300.2565truecovariatesfull set
80.14470.03300.2565trueoutlierswinsorize 1%
80.14470.03300.2565trueoutcomeraw
80.14470.03300.2565truesamplecomplete cases
90.14480.05660.2330truecovariatesfull set
90.14480.05660.2330trueoutlierswinsorize 1%
90.14480.05660.2330trueoutcomeraw
90.14480.05660.2330truesampleall
100.15160.06340.2398truecovariatesage + sex
100.15160.06340.2398trueoutlierswinsorize 1%
100.15160.06340.2398trueoutcomelog
100.15160.06340.2398truesampleall
110.15300.04130.2648truecovariatesnone
110.15300.04130.2648trueoutlierswinsorize 1%
110.15300.04130.2648trueoutcomelog
110.15300.04130.2648truesamplecomplete cases
120.15780.04600.2695truecovariatesage + sex
120.15780.04600.2695trueoutlierswinsorize 1%
120.15780.04600.2695trueoutcomelog
120.15780.04600.2695truesamplecomplete cases
130.15810.06990.2463truecovariatesage + sex
130.15810.06990.2463trueoutliersdrop |z| > 3
130.15810.06990.2463trueoutcomelog
130.15810.06990.2463truesampleall
140.16060.04890.2723truecovariatesfull set
140.16060.04890.2723trueoutliersdrop |z| > 3
140.16060.04890.2723trueoutcomeraw
140.16060.04890.2723truesamplecomplete cases
150.17470.08650.2629truecovariatesfull set
150.17470.08650.2629trueoutliersdrop |z| > 3
150.17470.08650.2629trueoutcomeraw
150.17470.08650.2629truesampleall

First 60 of 144 rows.

Open it in Charts for a guide to each panel.

03

What belongs on the curve

Read

Include a specification only if you'd have been willing to report it as your main analysis. Three questions help:

  • Does it estimate the same thing? A trimmed mean and a mean are different targets.
  • Is it statistically valid for these data?
  • Would a reasonable colleague have chosen it?

Leave out poor specifications and you hide a weakness in the result. Add them and you bury the good ones, so the set you list shapes the picture. Report how you chose it. Multiverse analysisMultiverse analysisRunning an analysis under every reasonable combination of data-processing and modeling choices. is the same idea, applied to data-processing choices as well.

04

Is it fair?

Checkpoint

Check yourself · choose all that apply

You're estimating the effect of a price change on revenue per user. Which belong on the curve? Choose all that apply.

Show the answer

Answer: a, b, c

The first three are defensible choices about the same question. The fourth doesn't estimate the effect at all, and the fifth selects on the outcome.

Check yourself

In a curve, every significant specification removes outliers, and every specification that keeps them isn't significant. How do you report this?

Show the answer

Answer: c

That pattern is the most useful thing a curve can show. Now you know exactly which rows to go and look at.

05

Not a vote

Predict

Predict first

Suppose 90% of 128 specifications are significant. Is that like 115 independent studies agreeing?

Yes: that's strong independent evidenceNo: the specifications all reuse the same data
Reveal

No. They all reuse the same rows, so they share the same luck. Removing one outlier changes all of them together. A curve shows how stable the result is to your choices. It doesn't add evidence, and a share of specifications isn't a p-value.

06

A small one by hand

Reflect

Run this on ToothGrowth: three transformations, three row subsets and two tests. Before you run it, write down which single choice you expect to matter most. Then check.

Python
import itertools
import numpy as np
import pandas as pd
from scipy import stats

df = pd.read_csv("toothgrowth.csv")
rows = []
subsets = {"all doses": [0.5, 1, 2], "without 2": [0.5, 1], "without 0.5": [1, 2]}
for tr, sub, welch in itertools.product(["raw", "log", "rank"], subsets, [True, False]):
    d = df[df["dose"].isin(subsets[sub])]
    y = {"raw": d["len"], "log": np.log(d["len"]), "rank": d["len"].rank()}[tr]
    r = stats.ttest_ind(y[d["supp"] == "OJ"], y[d["supp"] == "VC"], equal_var=not welch)
    rows.append((tr, sub, "Welch" if welch else "Student", r.statistic, r.pvalue))
print(pd.DataFrame(rows, columns=["outcome", "subset", "test", "t", "p"]).sort_values("t"))
R
df <- read.csv("toothgrowth.csv")
subsets <- list("all doses" = c(0.5, 1, 2), "without 2" = c(0.5, 1), "without 0.5" = c(1, 2))
grid <- expand.grid(outcome = c("raw", "log", "rank"), subset = names(subsets),
                    welch = c(TRUE, FALSE), stringsAsFactors = FALSE)
res <- t(apply(grid, 1, function(g) {
  d <- df[df$dose %in% subsets[[g[["subset"]]]], ]
  y <- switch(g[["outcome"]], raw = d$len, log = log(d$len), rank = rank(d$len))
  r <- t.test(y[d$supp == "OJ"], y[d$supp == "VC"], var.equal = g[["welch"]] == "FALSE")
  c(t = unname(r$statistic), p = r$p.value)
}))
cbind(grid, res)[order(res[, "t"]), ]
07

On your own result

In the app

Save and run an analysis, then press Specification curve in the header of its result card. Tick what may vary: Covariates, Outcome rules and transformations, Row subsets and Alternative methods. Then press Run.

The dialog reports specifications run, the share significant, the share with the same sign as your analysis, and the median estimate. Every specification lists them all. Nothing is saved as a new analysis or counted as a new test. In the Meta-analysis studio, Multiverse does this for pooled estimates.

08

How to write it up

Checkpoint

Check yourself

Which sentence reports a curve best?

Show the answer

Answer: c

Give the set, the range, the sign and what moved the result. "Robust" on its own tells the reader nothing about what you tried.

09

Recap

Recap
  • A specification curve replaces one chosen analysis with all the defensible ones, and shows what drives the result.
  • Include only specifications you'd have reported as your main analysis, and say how you chose them.
  • The specifications share data, so a share of them isn't a vote or a p-value.

Concepts in this lesson