dowhy
Causal inference framework for answering "does X cause Y?" beyond correlation. DoWhy (Microsoft Research) provides the identify-estimate-refute loop: define a causal graph (DAG), identify the causal effect using backdoor/frontdoor/instrumental variable criteria, estimate treatment effects with multi…
Install / Use
npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill dowhyInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
AutomationSupported Platforms
Our assessment of dowhy
dowhy scores 95/100 on our quality scale, 315th of 2,790 Automation skills we index (top 12%).
Its SKILL.md is 35 KB long, well organised into 203 sections with 21 code examples: a thorough specification that gives an agent plenty to work with.
With 4,360 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated about 2 months ago, so dowhy is actively maintained.
- Our last check on 2026-11-15 found the source still online.
- No license is declared. By default that means all rights are reserved: you can read it, but reusing or redistributing it is not clearly permitted. Ask the author before building on it commercially.
- Its trust signals score 88/100, with 1 caution from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-09-29. Automated pattern scan on 2026-09-28. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
dowhy compared with similar skills
All 4 of these similar skills score higher than dowhy; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| dowhy (this skill)by brycewang-stanford | 95 | 4.4k | 54d ago | SKILL.md |
| taste-skillby Leonxlnx | 100 | 116.8k | 8d ago | CLAUDE.md |
| Agent-Reachby Panniantong | 100 | 112.3k | 8d ago | CLAUDE.md |
| rufloby ruvnet | 100 | 81.9k | today | CLAUDE.md |
| Claude-Code-Game-Studiosby Donchitos | 100 | 39.7k | 7d ago | CLAUDE.md |
Frequently asked questions
- How do I install dowhy?
- Run
npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill dowhy. The install tabs above show the steps for each supported agent. - Which AI agents does dowhy work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is dowhy safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It declares no license and scores 88/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is dowhy still maintained?
- The repository was last updated about 2 months ago, so dowhy is actively maintained.
Skill content
View source on GitHubname: dowhy description: >- Causal inference framework for answering "does X cause Y?" beyond correlation. DoWhy (Microsoft Research) provides the identify-estimate-refute loop: define a causal graph (DAG), identify the causal effect using backdoor/frontdoor/instrumental variable criteria, estimate treatment effects with multiple estimators, and validate results with automated refutation tests. Use when: distinguishing causation from correlation, estimating treatment effects (ATE, ATT, CATE), designing and analyzing A/B tests with confounders, using instrumental variables, performing counterfactual reasoning ("what would have happened if..."), validating causal claims with sensitivity analysis, working with observational data where randomization is impossible, or any analysis where the question is "what is the CAUSAL effect of X on Y" rather than just "how do X and Y relate?" version: 0.11.0 license: MIT
DoWhy — Causal Inference
DoWhy answers the question every analyst actually wants answered: "Does X cause Y, or is it just correlated?" Correlation is everywhere. Causation requires structure — a causal graph that encodes which variables influence which. DoWhy's workflow is three steps: Identify (is the effect estimable from this graph?) → Estimate (compute the effect) → Refute (is this estimate robust?).
Core Mental Model
CORRELATION: X and Y move together. Could be:
X → Y (X causes Y)
Y → X (Y causes X)
X ← C → Y (C confounds both — spurious!)
CAUSATION: We need to know WHY they move together.
A causal graph (DAG) encodes our assumptions.
Then math tells us: "Given this graph,
CAN we estimate the causal effect from data?"
→ If yes: which variables to control for?
→ If no: what additional data do we need?
When to Use
- "Does this ad campaign actually increase sales, or do people who see ads already buy more?"
- "Does smoking cause cancer?" (observational data, can't randomize)
- "What would revenue have been if we hadn't changed the pricing?" (counterfactual)
- Any analysis where confounders exist and you have a theory about the causal structure.
When NOT to use: Pure prediction (use sklearn). Randomized controlled trials with no confounders (simple A/B test suffices). When you have no theory about the causal structure — you need at least a hypothesis about the DAG.
Reference Documentation
DoWhy docs: https://dowhy.readthedocs.io/en/latest/
GitHub: https://github.com/py-why/dowhy
Causal graph tutorials: https://dowhy.readthedocs.io/en/latest/tutorials.html
Search patterns: CausalModel, identify_effect, estimate_effect, refute_estimate
Core Principles
The Causal Graph (DAG)
A Directed Acyclic Graph where arrows mean "causes". A → B means A is a cause of B. This is your assumptions about the world — not learned from data. You draw it based on domain knowledge. The graph is what makes causal inference possible.
The Identify-Estimate-Refute Loop
- Identify: Given the DAG, is the causal effect of treatment on outcome estimable from observational data? Which variables must be controlled? (Backdoor criterion, frontdoor criterion, instrumental variables.)
- Estimate: Compute the effect using the identified strategy and a statistical method.
- Refute: Test robustness — would the estimate survive if our assumptions were wrong?
Confounders Are the Enemy
A confounder C is a common cause of both treatment and outcome: T ← C → Y. It creates spurious correlation. The entire point of causal inference is to block these backdoor paths.
Treatment Effect Types
- ATE (Average Treatment Effect): Effect across the whole population.
- ATT (Average Treatment Effect on the Treated): Effect on those who actually received treatment.
- CATE (Conditional ATE): Effect varies by subgroup — heterogeneous treatment effects.
Quick Reference
Installation
pip install dowhy networkx matplotlib pandas scikit-learn
Standard Imports
import dowhy
from dowhy import CausalModel
import pandas as pd
import numpy as np
Basic Pattern — Full Causal Pipeline
import numpy as np
import pandas as pd
from dowhy import CausalModel
# 1. Simulate data with a known causal structure:
# Confounder C → Treatment T, C → Outcome Y, T → Y (true effect = 2.0)
np.random.seed(42)
n = 2000
C = np.random.randn(n) # Confounder
T = (C + np.random.randn(n) > 0).astype(int) # Treatment influenced by C
Y = 2.0 * T + 1.5 * C + np.random.randn(n) # Outcome: true causal effect of T is 2.0
data = pd.DataFrame({'T': T, 'Y': Y, 'C': C})
# 2. Define the causal graph (YOUR ASSUMPTIONS)
graph = """
digraph {
C -> T;
C -> Y;
T -> Y;
}
"""
# 3. Create causal model
model = CausalModel(
data=data,
treatment=['T'],
outcome='Y',
graph=graph
)
# 4. IDENTIFY: Can we estimate the effect? How?
identified_effect = model.identify_effect()
print(identified_effect)
# → Backdoor criterion: control for C
# 5. ESTIMATE: Compute the causal effect
estimate = model.estimate_effect(
identified_effect,
estimation_method='backdoor.linear_regression'
)
print(f"Estimated causal effect of T on Y: {estimate.value:.3f}")
# → Should be close to 2.0 (the true effect we simulated)
# 6. REFUTE: Is this estimate robust?
refutation = model.refute_estimate(
estimate,
refutation_method='refute_placebo_treatment'
)
print(refutation)
# → Placebo effect should be ~0. If it is, our estimate is credible.
Critical Rules
✅ DO
- Draw the graph BEFORE looking at data — The DAG encodes your causal assumptions. It must come from domain knowledge, not from data patterns. Drawing it after seeing correlations defeats the purpose.
- Include ALL known confounders in the graph — Missing a confounder = biased estimate. When in doubt, include it.
- Always run at least 2 refutation tests — Placebo treatment + random common cause is the minimum. A single estimate without refutation is untrustworthy.
- Use multiple estimators and compare — If backdoor.linear_regression and backdoor.propensity_score give wildly different answers, your model assumptions may be wrong.
- Check positivity (overlap) — Propensity score methods fail if treatment and control groups don't overlap in covariate space. Visualize distributions.
- Report confidence intervals, not just point estimates — Use
estimate.get_confidence_intervals(). - Interpret ATE in context — An ATE of 0.5 means nothing without knowing the scale of Y.
❌ DON'T
- Don't assume correlation = causation and skip the graph — This is the entire reason DoWhy exists.
- Don't use DoWhy without a causal hypothesis — If you have no theory about why X might cause Y, you cannot draw a valid DAG. Go do qualitative research first.
- Don't ignore refutation failures — If placebo treatment gives a non-zero effect, your estimate is suspect. Investigate, don't just report.
- Don't confuse "not statistically significant" with "no causal effect" — Underpowered studies fail to detect real effects. Sample size matters.
- Don't use backdoor adjustment when backdoor criterion isn't satisfied —
identify_effect()tells you which strategy is valid. Trust it. - Don't assume linearity —
backdoor.linear_regressionassumes linear relationships. If the truth is nonlinear, usebackdoor.propensity_score_weightingorbackdoor.propensity_score_matching.
Anti-Patterns (NEVER)
import numpy as np
import pandas as pd
from dowhy import CausalModel
# ❌ BAD: No graph — just "estimate" the effect (this is regression, not causal inference)
data = pd.DataFrame({'T': [0,1,0,1], 'Y': [1,3,2,4], 'C': [0.5,1.2,0.8,1.5]})
# This is NOT causal inference — it's just OLS regression. No confounders controlled.
# model = CausalModel(data=data, treatment=['T'], outcome='Y', graph=None) # ← WRONG
# ✅ GOOD: Explicit graph with confounders
graph = "digraph { C -> T; C -> Y; T -> Y; }"
model = CausalModel(data=data, treatment=['T'], outcome='Y', graph=graph)
# ─────────────────────────────────────────────────────────────
# ❌ BAD: Graph drawn AFTER looking at data correlations
# "T and C correlate strongly, so let's put C → T"
# "Y and C correlate, so C → Y"
# This is data-driven graph construction — circular reasoning!
# The graph must come from DOMAIN KNOWLEDGE.
# ✅ GOOD: Graph from theory
# "We know from epidemiology that smoking history (C) affects both
# whether someone enrolls in the program (T) and health outcomes (Y)"
# THEN encode: C -> T; C -> Y; T -> Y
# ─────────────────────────────────────────────────────────────
# ❌ BAD: Single estimator, no refutation — "done"
identified = model.identify_effect()
estimate = model.estimate_effect(identified, estimation_method='backdoor.linear_regression')
print(f"Effect = {estimate.value}") # And that's it. Trust this number? Why?
# ✅ GOOD: Multiple estimators + refutation battery
est_lr = model.estimate_effect(identified, estimation_method='backdoor.linear_regression')
est_psm = model.estimate_effect(identified, estimation_method='backdoor.propensity_score_matching')
est_psw = model.estimate_effect(identified, estimation_method='backdoor.propensity_score_weighting')
print(f"Linear Regression: {est_lr.value:.3f}")
print(f"Propensity Matching: {est_psm.value:.3f}")
print(f"Propensity Weighting: {est_psw.value:.3f}")
# If all three agree → high confidence. If they diverge → investigate.
# Refutation battery
model.refute_estimate(est_lr, refutation_method='refute_placebo_treatment')
model.refute_estimate(est_lr, refutation_method='refute_random_common_cause')
model.refute_estimate(est_lr, refutation_method='refute_data_subset')
# ─────────────────────────────────────────────────────────────
# ❌ BAD: Ignoring the identification result
identified = model.identify_effect()
# identified says: "Backdoor criterion NOT satisfied with these variables"
# But we proceed anyway with backdoor adjustment → biased estimate!
# ✅ GOOD: Check identification, switch strategy if needed
identified = model.identify_effect()
if identified.get_backdoor_variables():
estimate = model.estimate_effect(identified, estimation_method='backdoor.linear_regression')
elif identified.get_instrumental_variables():
estimate = model.estimate_effect(identified, estimation_method='iv.instrumental_variable')
else:
print("Effect is NOT identifiable from this graph. Need more data or stronger assumptions.")
Causal Graphs — Building Blocks
DAG Syntax
from dowhy import CausalModel
# Arrows: A -> B means "A causes B"
# Multiple paths: C -> T and C -> Y means C confounds T and Y
# Simple: treatment, outcome, one confounder
graph_simple = """
digraph {
C -> T;
C -> Y;
T -> Y;
}
"""
# Multiple confounders
graph_multi = """
digraph {
C1 -> T; C1 -> Y;
C2 -> T; C2 -> Y;
C3 -> Y;
T -> Y;
}
"""
# C1, C2 confound. C3 affects only Y (not a confounder, but still important).
# Mediator: T → M → Y (T affects Y *through* M)
graph_mediator = """
digraph {
T -> M;
M -> Y;
T -> Y;
C -> T; C -> Y;
}
"""
# Total effect of T on Y = direct (T→Y) + indirect (T→M→Y)
# Collider: T → S ← Y (S is caused by BOTH T and Y)
# NEVER condition on a collider — it opens a spurious path!
graph_collider = """
digraph {
T -> S;
Y -> S;
T -> Y;
}
"""
# Instrumental Variable: Z → T → Y, Z does NOT directly affect Y
graph_iv = """
digraph {
Z -> T;
T -> Y;
C -> T; C -> Y;
}
"""
# Z is valid instrument if: (1) Z affects T, (2) Z affects Y ONLY through T
Graph Visualizat
Truncated for display — read the full file on GitHub.
Related Skills
taste-skill
116.8kAgent skills that give coding agents taste: art direction, reference images and a browser check instead of generic AI pages
Agent-Reach
112.3kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
ruflo
81.9k🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
Claude-Code-Game-Studios
39.7kTurn Claude Code into a full game dev studio — 49 AI agents, 72 workflow skills, and a complete coordination system mirroring real studio hierarchy.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
