process-causal-inference-dags
>- Build a DAG for a process-data problem, test d-separation, enumerate back-door adjustment sets, and export to Graphviz DOT for review. Use when designing an observational study or distinguishing confounding from mediation. Don't use to estimate causal effects (that is a separate modelling task);
- License 许可
- MIT
- 最近更新
- 2026-11-09
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- process-causal-inference-dags
- risk
- low
- source
- https://github.com/jskherman/engg-skills
- license
- MIT
- version
- 1.0.0
- category
- chemical-engineering
- description
- >- Build a DAG for a process-data problem, test d-separation, enumerate back-door adjustment sets, and export to Graphviz DOT for review. Use when designing an observational study or distinguishing confounding from mediation. Don't use to estimate causal effects (that is a separate modelling task);
- imported_at
- 2026-09-20
- source_path
- skills/process-causal-inference-dags/SKILL.md
- source_repository
- jskherman/engg-skills
- disable-model-invocation
- false
02 资源文件 2
- 参考文档references/dag_glossary.md2.1 KB
- 脚本scripts/dag.py3.8 KB
03 SKILL.md 正文
Process Causal Inference (DAG-Based Adjustment)
Overview
For observational process data, the right adjustment set determines whether a regression coefficient is a confounded estimate, a partial mediated estimate, or the total effect. This skill provides DAG tooling:
- Build a DAG from an edge list (YAML or CLI).
- Test d-separation between sets given conditioning.
- Enumerate parents of the treatment as a candidate back-door adjustment set; verify the criterion.
- Export DOT source for the user to render with Graphviz.
The implementation is pure-Python (no NetworkX dependency). For larger
problems, swap in networkx/pgmpy.
Scope is deliberately narrow per design review:
- It DOES NOT estimate causal effects. Pair it with
engineering-statistics,censored-regression,distributed-lag-models, orbayesian-hierarchical-process-modelsfor that. - It DOES NOT do front-door or instrument-variable analysis. Extend as needed.
Prerequisites
uvavailable.- On first use, the script writes
LICENSE_NOTIFICATION.txt.
When to Use
- Designing an observational study and you need a defensible adjustment set.
- Resolving confounding-vs-mediation disagreements in plant data.
- Drawing a DAG for an internal report or for HAZOP-style review of an empirical claim.
Don't use for
- Estimating effect sizes (see other skills).
- Bayesian network learning from data (use
pgmpy). - Counterfactual analysis (no potential-outcomes implementation here).
Utility Scripts
uv run scripts/dag.py check --edges "A,B;A,C;B,D;C,D" --treatment B --outcome D --output /tmp/check.jsonuv run scripts/dag.py dsep --edges "A,B;A,C;B,D;C,D" --x B --y C --z A --output /tmp/dsep.jsonuv run scripts/dag.py dot --edges "A,B;A,C;B,D;C,D" --output /tmp/g.dot
Procedure
- List variables (predictors, candidate confounders, mediators, colliders, regime indicators, lab outcomes).
- Classify each variable (confounder vs mediator vs collider vs regime).
- Draw the DAG (one edge per causal direction; no cycles).
- Identify the treatment and the outcome.
- Get the parent set of the treatment; verify it satisfies the back-door
criterion via
check. - Use d-separation tests for alternative paths.
- Export DOT and render externally for review.
Pitfalls
- Adjusting for mediators when estimating a total effect; this introduces bias.
- Adjusting for colliders (variables caused by both treatment and outcome); this opens a spurious path.
- Drawing an unsigned graph and assuming the direction is obvious; always be explicit.
- Equating "correlation with the outcome" with "is a confounder"; a mediator is correlated too but should not be adjusted for total effect.
- Forgetting the regime / selection indicator; if operators routinely intervene in response to the outcome, that intervention may be a collider conditional on the response.
- Reporting "no confounding" because a regression coefficient barely moves with adjustment. The right test is graphical, not numerical.
- Treating descendants of the treatment as legitimate adjustment variables.
Fallback Strategies
- If the DAG has many nodes (> ~30), switch to
networkx+pgmpyfor efficient enumeration of separation sets.
Verification
- Run the listed script with representative inputs and an
--outputfile when a deterministic calculation is available. - Confirm the JSON result contains
ok: true, expected units, and no unhandled warnings. - Check result magnitudes against the stated assumptions, references, and a hand calculation or known operating range before reporting them.
References
references/dag_glossary.md— confounders, mediators, colliders, back-door criterion.- Pearl, Causality (2nd ed).
- Hernán & Robins, Causal Inference: What If.
Anti-Patterns
- Drawing a DAG only after seeing the regression results.
- Adjusting "for everything"; that controls for mediators and colliders.
- Claiming causal effect from a coefficient without naming the DAG used.
04 同仓库更多 Skills
dei-assessment
Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.
dei-action-plan
Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.
culture-fit-assessment
Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.
cowork-to-code-bridge
Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.
counter-offer-response
Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.
continuous-feedback-system
Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.