Skip to main content

You have no obligation to share your data and code

How science behaves
Law or aphorism
Introductory
And I have no obligation to believe anything you write.
Published

November 9, 2026

Modified

November 13, 2026

Entry #150 in Andrew Gelman’s Handy Statistical Lexicon. Original discussion: The authors of research papers have no obligation to share their data and code, and I have no obligation to believe anything they write.

Filed under How science behaves · Law or aphorism · Introductory.

Source check: ✓ The explanation was checked against the source.

What it is

Gelman doesn’t argue that authors must be forced to share. There are sometimes legitimate reasons not to, such as privacy or proprietary data. His point is about what follows for readers. A claim whose data and code can’t be checked deserves less belief. Sharing is how authors earn credibility, and refusing to share has an evidential cost that readers are entitled to apply.

Why it matters

Analyses contain errors at some base rate (see Mistakes). Shared data and code let errors be found, so a shared result that has survived checking is more credible. An unshared result keeps its full prior chance of error. And if authors who know their analysis is shaky are less likely to share, then not sharing is itself evidence. Readers who give unshared results the same trust as checked ones are ignoring both effects.

How it works

A toy model. Each published result is wrong with prior probability \(e\). Shared results get checked, and errors are found with probability \(d\). Authors of erroneous analyses share less often, at rate \(s_{\text{wrong}} < s_{\text{right}}\). By Bayes’ rule, a reader’s probability that a result is correct is highest for “shared and checked, no error found” and lowest for “not shared,” which comes out below the base rate whenever \(s_{\text{wrong}} < s_{\text{right}}\).

Simulated example

There are 5,000 published results. Vary the base error rate and how much less likely authors of flawed analyses are to share. Compare the reader’s credence by sharing status.

Show simulation code

The R version uses base R, and the Python version uses NumPy and Matplotlib. Where the simulation draws random numbers, each language draws its own, so exact numbers differ slightly but show the same pattern. The numbered markers in the R code are explained under it.

import {rng, range, mean, pct} from "../js/stats.js"

viewof e = Inputs.range([0.05, 0.5], {value: 0.25, step: 0.01, label: "Base rate of serious errors"})
viewof sRight = Inputs.range([0.1, 1], {value: 0.7, step: 0.05, label: "Pr(share) if the analysis is sound"})
viewof sWrong = Inputs.range([0, 1], {value: 0.35, step: 0.05, label: "Pr(share) if the analysis is flawed"})
viewof seed = Inputs.range([1, 500], {value: 150, step: 1, label: "Random seed"})

share = {
  const r = rng(seed);
  const d = 0.7;
  const rows = range(5000).map(() => {
    const wrong = r() < e, shared = r() < (wrong ? sWrong : sRight);
    const caught = shared && wrong && r() < d;
    return {wrong, status: !shared ? "Not shared" : caught ? "Shared: error found" : "Shared: checks out"};
  });
  return ["Shared: checks out", "Not shared", "Shared: error found"].map(st => {
    const g = rows.filter(x => x.status === st);
    return {status: st, n: g.length, correct: g.length ? mean(g.map(x => +!x.wrong)) : NaN};
  });
}

Plot.plot({
  ariaLabel: "You have no obligation to share your data and code: simulation chart",
  ariaDescription: "Horizontal axis: Probability the result is correct. The chart updates with the controls above it, and the summary below the charts states the result in words.",
  height: 200,
  marginLeft: 150,
  x: {label: "Probability the result is correct", domain: [0, 1], tickFormat: "%", grid: true},
  y: {label: null},
  marks: [Plot.barX(share, {y: "status", x: "correct", fill: d => d.status === "Not shared" ? "#d6604d" : d.status.includes("checks") ? "#2166ac" : "#8a8a8a"}), Plot.ruleX([1 - e], {stroke: "currentColor", strokeDasharray: "4 3"})]
})
# You have no obligation to share your data and code (but it is a signal).
1e <- 0.25 # base rate of serious errors
s_right <- 0.7 # probability of sharing if the analysis is sound
s_wrong <- 0.35 # probability of sharing if the analysis is flawed
2set.seed(150)

wrong <- runif(5000) < e
3shared <- runif(5000) < ifelse(wrong, s_wrong, s_right)
4caught <- shared & wrong & runif(5000) < 0.7 # checkers find 70% of errors
status <- ifelse(!shared, "Not shared",
  ifelse(caught, "Shared: error found", "Shared: checks out")
)

5correct <- tapply(!wrong, status, mean)
print(round(100 * correct)) # % of analyses that are correct, by status

6barplot(
  100 * correct[c(
    "Shared: checks out", "Not shared",
    "Shared: error found"
  )],
  col = c("#2166ac", "grey70", "#d6604d"),
  ylab = "Analyses that are correct (%)", ylim = c(0, 100)
)
1
The page’s controls: the base rate of serious errors, and the probability of sharing when the analysis is sound and when it is flawed.
2
Fixes the random numbers so the run is reproducible.
3
Authors of flawed analyses share less often. That is what makes not sharing a signal.
4
Shared analyses get checked, and most errors are found.
5
By Bayes’ rule, the share of correct analyses in each group.
6
Not shared sits between checks-out and error-found: no obligation, but readers may draw their conclusions.
# You have no obligation to share your data and code (but it is a signal).
import numpy as np
import matplotlib.pyplot as plt

e = 0.25        # base rate of serious errors
s_right = 0.7   # probability of sharing if the analysis is sound
s_wrong = 0.35  # probability of sharing if the analysis is flawed
rng = np.random.default_rng(150)

wrong = rng.uniform(size=5000) < e
shared = rng.uniform(size=5000) < np.where(wrong, s_wrong, s_right)
caught = shared & wrong & (rng.uniform(size=5000) < 0.7)  # 70% found
groups = {"Shared: checks out": shared & ~caught, "Not shared": ~shared,
          "Shared: error found": caught}
correct = {k: 100 * np.mean(~wrong[g]) for k, g in groups.items()}
for k, v in correct.items():
    print(f"{k}: {v:.0f}% of analyses are correct")

plt.bar(list(correct), list(correct.values()),
        color=["#2166ac", "0.7", "#d6604d"])
plt.ylim(0, 100)
plt.ylabel("Analyses that are correct (%)")
plt.show()

Key takeaways

  • Sharing data and code is how a result earns credibility.
  • When flawed analyses are shared less often, not sharing is itself evidence against a result.
  • Readers can adjust their belief according to whether a result can be checked.

Source

Back to top