liveBook · Manning

P-hacking

As explained in Grokking Statistics

P-hacking is the selective analysis or threshold manipulation of data to obtain or present a statistically significant result.

P-hacking means shopping among models, variables, data choices, or analysis decisions until a desired result appears—often a low p-value or statistically significant finding. It can be deliberate, but it often begins as an innocent attempt to make a model work and gradually turns into confirmation bias. section 9.12

Common forms of p-hacking include:

  • Collecting only enough data to obtain the desired result. section 9.14
  • Removing inconvenient observations as outliers or noise without justification. section 9.14
  • Shopping for variables, model parameters, or subgroups that produce favorable findings. section 9.14
  • Repeating train/test splits and model changes until one performs well on the test set. section 9.14

Torturing a test set

A practitioner repeatedly changes the model and data after inspecting test performance. A strong final score may look convincing, but the test set has leaked clues into the training process. Holding out a separate validation dataset provides an additional check on data that was never part of that iterative testing. section 9.14

The practical defense is self-awareness: notice when the analysis is confirming a preferred answer, step back, reconsider the approach, and remain willing to find contrary data. Pressure from research funding, jobs, clients, or startup demonstrations can make cherry-picking especially tempting. section 9.12 section 9.15

How Grokking Statistics covers it

How deep it goes
Explains the definition, common modeling behaviors, test-set leakage, incentives, and basic mitigation without formal statistical derivations.
Examples
Uses selective data collection, unjustified outlier removal, subgroup shopping, and repeated model tuning against a test set.
What it assumes
Assumes familiarity with data analysis, statistical significance, p-values, and train/test splits.
What you can do after
Diagnose p-hacking by recognizing cherry-picked analyses, test-set leakage, and pressures favoring results, then re-evaluate for contrary evidence.
How it connects
Connects p-hacking to confirmation bias, overfitting, train/test splits, validation datasets, and confounding variables.

Also explained in

Compare how 3 books explain p-hacking →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Statistics. The section links point to the parts of the book it draws on.