# Process Causal Inference Dags

> >-

- **Type:** Skill
- **Install:** `agentstack add skill-jskherman-engg-skills-process-causal-inference-dags`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [jskherman](https://agentstack.voostack.com/s/jskherman)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [jskherman](https://github.com/jskherman)
- **Source:** https://github.com/jskherman/engg-skills/tree/main/skills/process-causal-inference-dags

## Install

```sh
agentstack add skill-jskherman-engg-skills-process-causal-inference-dags
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 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`, or
  `bayesian-hierarchical-process-models` for that.
- It DOES NOT do front-door or instrument-variable analysis. Extend as
  needed.

## Prerequisites

1. `uv` available.
2. 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.json`
- `uv run scripts/dag.py dsep --edges "A,B;A,C;B,D;C,D" --x B --y C --z A --output /tmp/dsep.json`
- `uv run scripts/dag.py dot --edges "A,B;A,C;B,D;C,D" --output /tmp/g.dot`

## Procedure

1. List variables (predictors, candidate confounders, mediators, colliders,
   regime indicators, lab outcomes).
2. Classify each variable (confounder vs mediator vs collider vs regime).
3. Draw the DAG (one edge per causal direction; no cycles).
4. Identify the treatment and the outcome.
5. Get the parent set of the treatment; verify it satisfies the back-door
   criterion via `check`.
6. Use d-separation tests for alternative paths.
7. 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` + `pgmpy` for
  efficient enumeration of separation sets.

## Verification

- Run the listed script with representative inputs and an `--output` file 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.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [jskherman](https://github.com/jskherman)
- **Source:** [jskherman/engg-skills](https://github.com/jskherman/engg-skills)
- **License:** Apache-2.0

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-jskherman-engg-skills-process-causal-inference-dags
- Seller: https://agentstack.voostack.com/s/jskherman
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
