whyflow

Statistical workflows that carry their reasons.

Draw the causal model, write down why each step exists, and prove the estimator works on simulated data before you trust it on real data. whyflow turns that workflow into one page you can share, with the code of every step attached to the diagram.

Try it in your browser GitHub pip install whyflow
Clicking through a whyflow report

Example reports

Each one is built from the examples in the repository, on every change, including three classics from Statistical Rethinking. Two are built to fail, because catching the mistake is the point.

the effect you want bias leaking in

The right way

Total effect of age on children's weight, written as a simulation. Height is a mediator, so the estimator leaves it alone. Every check passes.

graph LR
    age["age"]:::focus
    height["height"]:::plain
    weight["weight"]:::focus
    age e0@--> height
    age e1@--> weight
    height e2@--> weight
    linkStyle 0,1,2 stroke:#16a34a,stroke-width:3px
    classDef focus fill:#1f2937,stroke:#1f2937,color:#ffffff,stroke-width:1px
    classDef good fill:#dcfce7,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef bad fill:#fee2e2,stroke:#dc2626,color:#7f1d1d,stroke-width:3px
    classDef suggest fill:#ffffff,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef plain fill:#f3f4f6,stroke:#9ca3af,color:#374151,stroke-width:1px
    classDef suggest stroke-dasharray:6 3
diagram check: passedrecovery test: passed · caught the truth 97%hidden confounder breaks it at 0.75
Open the report →

Book ch. 6: the plant fungus

A yes/no treatment that works by stopping fungus. Leave fungus out and the effect is found; 'control for' it and the estimate collapses from 1.2 to 0.

graph LR
    h0["h0<br/><small>adjusted</small>"]:::good
    treatment["treatment"]:::focus
    fungus["fungus"]:::plain
    h1["h1"]:::focus
    treatment e0@--> fungus
    fungus e1@--> h1
    h0 e2@--> h1
    linkStyle 0,1 stroke:#16a34a,stroke-width:3px
    classDef focus fill:#1f2937,stroke:#1f2937,color:#ffffff,stroke-width:1px
    classDef good fill:#dcfce7,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef bad fill:#fee2e2,stroke:#dc2626,color:#7f1d1d,stroke-width:3px
    classDef suggest fill:#ffffff,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef plain fill:#f3f4f6,stroke:#9ca3af,color:#374151,stroke-width:1px
    classDef suggest stroke-dasharray:6 3
diagram check: passedrecovery test: passed · caught the truth 96%hidden confounder breaks it at 0.5
Open the report →

Book ch. 11: admissions

A yes/no outcome. The true effect is a change in probability, so the estimator reports that, not the logistic regression's log-odds coefficient.

graph LR
    gender["gender"]:::focus
    department["department"]:::plain
    admitted["admitted"]:::focus
    gender e0@--> department
    department e1@--> admitted
    linkStyle 0,1 stroke:#16a34a,stroke-width:3px
    classDef focus fill:#1f2937,stroke:#1f2937,color:#ffffff,stroke-width:1px
    classDef good fill:#dcfce7,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef bad fill:#fee2e2,stroke:#dc2626,color:#7f1d1d,stroke-width:3px
    classDef suggest fill:#ffffff,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef plain fill:#f3f4f6,stroke:#9ca3af,color:#374151,stroke-width:1px
    classDef suggest stroke-dasharray:6 3
diagram check: passedrecovery test: passed · caught the truth 98%hidden confounder breaks it at 0.5
Open the report →

Book ch. 5: Waffle Houses and divorce

Tested on a simulation where waffles do nothing, then run on the real 50 states: no effect once the South is accounted for.

graph LR
    South["South<br/><small>adjusted</small>"]:::good
    MedianAgeMarriage["MedianAgeMarriage"]:::plain
    Marriage["Marriage"]:::plain
    WaffleHouses["WaffleHouses"]:::focus
    Divorce["Divorce"]:::focus
    South e0@--> MedianAgeMarriage
    MedianAgeMarriage e1@--> Marriage
    South e2@--> WaffleHouses
    Marriage e3@--> Divorce
    MedianAgeMarriage e4@--> Divorce
    classDef focus fill:#1f2937,stroke:#1f2937,color:#ffffff,stroke-width:1px
    classDef good fill:#dcfce7,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef bad fill:#fee2e2,stroke:#dc2626,color:#7f1d1d,stroke-width:3px
    classDef suggest fill:#ffffff,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef plain fill:#f3f4f6,stroke:#9ca3af,color:#374151,stroke-width:1px
    classDef suggest stroke-dasharray:6 3
diagram check: passedrecovery test: passed · caught the truth 97%hidden confounder breaks it at 1
Open the report →

The mediator mistake

Same question, but the estimator 'controls for' height. It feels careful, and it throws away most of the effect: 0.5 instead of 1.3.

graph LR
    age["age"]:::focus
    height["height<br/><small>adjusted</small>"]:::bad
    weight["weight"]:::focus
    age e0@-->|2.0| height
    age e1@-->|0.5| weight
    height e2@-->|0.4| weight
    linkStyle 0,1,2 stroke:#16a34a,stroke-width:3px
    classDef focus fill:#1f2937,stroke:#1f2937,color:#ffffff,stroke-width:1px
    classDef good fill:#dcfce7,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef bad fill:#fee2e2,stroke:#dc2626,color:#7f1d1d,stroke-width:3px
    classDef suggest fill:#ffffff,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef plain fill:#f3f4f6,stroke:#9ca3af,color:#374151,stroke-width:1px
    classDef suggest stroke-dasharray:6 3
diagram check: failedrecovery test: failed · caught the truth 0%
Open the report →

The haunted DAG

McElreath's chapter 6 example. An unmeasured neighborhood confounds parents and children, and no adjustment can fix it. whyflow says so before touching data.

graph LR
    U["U"]:::plain
    G["G<br/><small>adjusted</small>"]:::good
    P["P"]:::focus
    C["C"]:::focus
    G e0@-->|1.0| P
    U e1@-->|2.0| P
    e1@{ animate: true }
    P e2@-->|1.0| C
    G e3@-->|0.0| C
    U e4@-->|2.0| C
    e4@{ animate: true }
    linkStyle 1,4 stroke:#dc2626,stroke-width:3px
    linkStyle 2 stroke:#16a34a,stroke-width:3px
    classDef focus fill:#1f2937,stroke:#1f2937,color:#ffffff,stroke-width:1px
    classDef good fill:#dcfce7,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef bad fill:#fee2e2,stroke:#dc2626,color:#7f1d1d,stroke-width:3px
    classDef suggest fill:#ffffff,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef plain fill:#f3f4f6,stroke:#9ca3af,color:#374151,stroke-width:1px
    classDef suggest stroke-dasharray:6 3
    style U stroke-dasharray:5 4
diagram check: failedrecovery test: failed · caught the truth 0%
Open the report →

Real data: the !Kung San

Nancy Howell's census, as used in Statistical Rethinking. The estimator passes both tests on simulated data, then runs on the real children: about 1.34 kg per year.

graph LR
    age["age"]:::focus
    height["height"]:::plain
    weight["weight"]:::focus
    age e0@-->|5.0| height
    age e1@-->|0.1| weight
    height e2@-->|0.25| weight
    linkStyle 0,1,2 stroke:#16a34a,stroke-width:3px
    classDef focus fill:#1f2937,stroke:#1f2937,color:#ffffff,stroke-width:1px
    classDef good fill:#dcfce7,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef bad fill:#fee2e2,stroke:#dc2626,color:#7f1d1d,stroke-width:3px
    classDef suggest fill:#ffffff,stroke:#16a34a,color:#14532d,stroke-width:3px
    classDef plain fill:#f3f4f6,stroke:#9ca3af,color:#374151,stroke-width:1px
    classDef suggest stroke-dasharray:6 3
diagram check: passedrecovery test: passed · caught the truth 95%hidden confounder breaks it at 0.75
Open the report →

What it checks

Three checks, each one a step in the diagram, with its code and result in the report.

Every step says why

A step without a reason is refused. Analysis steps that use an untested estimator get a warning: test before you invest.

Good and bad controls

From the causal diagram alone: mediators, colliders, open back doors, and the smallest set of variables that removes the bias, or a clear "nothing can".

Recovery on simulated data

100 simulated datasets where the truth is known. Does the estimator find it, and do its ranges catch it as often as they promise?

Why it exists

In the 2026 run of Statistical Rethinking, Richard McElreath said he knew of no tool that builds an analysis as a workflow and attaches the code of each step to the diagram, and asked if anyone watching would write one. Pipeline software records what ran; this records why. whyflow is one answer to that request.