Skip to content
StatsOtter A workspace for causal thinking
Method library WORKFLOW / 032
Research workflow/4 steps

Model, identify, estimate, refute — the DoWhy four-step recipe (DoWhy)

Source DoWhy — PyWhy / Microsoft (Sharma, Kiciman et al.)
01
The method workspace

Follow the analysis.

Select a node to explore the method

Method mapInput → 4 steps → output
START WITHInput data
ARRIVE ATResults
Read step 01
Inside the methodReasoning, equations & implementation
Step 1 of 4
01
Data prep

Model — encode the causal graph

Data preparation — shapes the raw inputs into what the estimator expects.

What happens here

State the DAG over treatment, outcome, confounders and instruments. The assumptions go in up front, as a graph, not buried in a regression.

Formula
\tau=\mathbb{E}\big[Y\mid do(T{=}1)\big]-\mathbb{E}\big[Y\mid do(T{=}0)\big]
Reads fromNot specified Feeds intoNot specified
Key code
from dowhy import CausalModel
model = CausalModel(data=df, treatment='v0', outcome='y', graph=gml_graph)

Reference / docs ↗

Discussion on this step (0)
StatsOtterDiscussion starter · Editorial note

Before using this step, make its assumptions and its output explicit. A useful peer note explains what you would check, what could go wrong, or what would change your interpretation.

Questions to explore
  1. Which assumption matters most here, and what evidence could challenge it?
  2. What would you check before passing this output to the next step?

Peer discussion

  • Bring your experience, a question, or a different perspective.
02
Data contract

Inputs & data

A dataset plus a causal graph (DAG) naming treatment, outcome, confounders and any instruments — the assumptions you're willing to defend.

Show data format & exampleHide example

Format — a tidy table together with a causal graph (DOT/GML) over treatment v0, outcome y and confounders W*.

import dowhy.datasets
d = dowhy.datasets.linear_dataset(
        beta=10, num_common_causes=5, num_instruments=1, num_samples=1000)
# d['df']: v0 (treatment), y (outcome), W0..W4 (confounders), X0
03
Read the evidence

Results & interpretation

2 figures Workflow discussion 2
01FigureThe assumed causal graph: confounders W0–W4 point into both the treatment v0 and the outcome y; DoWhy reads identifiability straight off this DAG.
02FigureRefutation — 'effect of an unobserved common cause': how the estimate shifts as a hypothetical confounder's strength on treatment and outcome grows.

Figures reproduced from DoWhy — PyWhy / Microsoft (Sharma, Kiciman et al.) — unofficial community showcase; all credit to the original authors.

Context & interpretation

⚠️ Unofficial community showcase of dowhy. Not affiliated with the authors; all credit to them.

Make your assumptions explicit: draw a causal graph, identify the estimand by the backdoor criterion, estimate it, then actively try to refute it with placebo and confounding tests.

Peer notes

Discuss the workflow (2)

  • 2

    The refute step is what sells DoWhy to me — placebo and random-common-cause as a default habit, not an afterthought.

  • 1

    Encoding the DAG up front forces the awkward assumptions into the open. Wish more pipelines did this.

    1

    Exactly — identification before estimation. The backdoor set is a modelling decision, not a tuning knob.

IN THE MARGINS

Peer discussion