process-causal-inference-dags
Skill7 starsChanged 6 months agoApache-2.0View on GitHub
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); the skill produces the adjustment set, not the estimate.
In this repository31 other files it gives its agents.
- absorption-stripping-designSkill
- bayesian-hierarchical-process-modelsSkill
- caustic-merox-extractionSkill
- censored-regressionSkill
- compositional-data-analysisSkill
- control-valve-sizing-isa75Skill
- convective-heat-transfer-correlationsSkill
- design-of-experimentsSkill
- dimensionless-numbersSkill
- distillation-shortcut-designSkill
- distributed-lag-modelsSkill
- engg-skills-commonSkill
- engineering-skill-creatorSkill
- engineering-statisticsSkill
- equation-of-state-selectionSkill
- heat-exchanger-sizingSkill
- literature-search-engineeringSkill
- material-energy-balancesSkill
- pipe-flow-pressure-dropSkill
- process-units-conversionSkill
- reactor-sizing-and-kineticsSkill
- relief-valve-sizing-api520Skill
- separator-vessel-sizingSkill
- sour-gas-amine-treatingSkill
- statistical-process-controlSkill
- steam-tables-iapwsSkill
- thermo-process-propertiesSkill
- time-series-process-data-analysisSkill
- two-phase-flowSkill
- uvSkill
- vle-flash-calculationsSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Test d-separation between sets given conditioning.
- Distinctive: line 78
Use d-separation tests for alternative paths.
- Very specific: line 100
If the DAG has many nodes (> ~30), switch to networkx + pgmpy for efficient enumeration of separation sets.
- Very specific: line 105
Run the listed script with representative inputs and an --output file when a deterministic calculation is available.
- Distinctive: line 107
Check result magnitudes against the stated assumptions, references, and a hand calculation or known operating range before reporting them.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

