skills/26-Data-Wise-scholar/skills/mathematical/identification-theory/SKILL.md
DAG and potential outcomes frameworks for causal mediation identification
npx skillsauth add brycewang-stanford/Awesome-Agent-Skills-for-Empirical-Research identification-theoryInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Comprehensive framework for causal identification in statistical methodology
Use this skill when working on: causal identification, mediation analysis identification, DAG-based reasoning, potential outcomes, identification assumptions, partial identification, sensitivity analysis, or deriving identification formulas.
A causal parameter $\psi$ is identified if it can be uniquely determined from the observed data distribution $P(O)$.
Formally: $\psi$ is identified if $P_1(O) = P_2(O) \Rightarrow \psi_1 = \psi_2$.
Causal Question → Target Estimand → Identification → Estimation → Inference
↓ ↓ ↓ ↓ ↓
"Does A E[Y(1)-Y(0)] Express in Statistical Confidence
cause Y?" terms of P(O) methods intervals
Without identification, no amount of data can answer causal questions.
Primitives:
Advantages:
Primitives:
Advantages:
A DAG $\mathcal{G} = (V, E)$ consists of:
| Term | Definition | Notation | |------|------------|----------| | Parents | Direct causes | $PA_Y$ | | Children | Direct effects | $CH_Y$ | | Ancestors | All causes | $AN_Y$ | | Descendants | All effects | $DE_Y$ | | Collider | Node with two incoming arrows | $A \to C \leftarrow B$ | | Mediator | Node on causal path | $A \to M \to Y$ | | Confounder | Common cause | $A \leftarrow C \to Y$ |
# DAG specification and visualization using dagitty
library(dagitty)
# Define mediation DAG
mediation_dag <- dagitty('
dag {
A [exposure]
M [mediator]
Y [outcome]
X [confounder]
X -> A
X -> M
X -> Y
A -> M
A -> Y
M -> Y
}
')
# Visualize
plot(mediation_dag)
# Find adjustment sets
adjustmentSets(mediation_dag, exposure = "A", outcome = "Y")
# Check implied conditional independencies
impliedConditionalIndependencies(mediation_dag)
Two nodes $A$ and $B$ are d-separated by set $Z$ if every path between them is blocked.
| Path Type | Blocked by conditioning on... | |-----------|-------------------------------| | Chain: $A \to M \to B$ | $M$ (blocks) | | Fork: $A \leftarrow C \to B$ | $C$ (blocks) | | Collider: $A \to C \leftarrow B$ | NOT $C$ (conditioning opens!) |
$$A \perp!!!\perp_{\mathcal{G}} B \mid Z \iff \text{every path } A \text{---} B \text{ is blocked by } Z$$
# Check d-separation using dagitty
check_dseparation <- function(dag, x, y, z = NULL) {
if (is.null(z)) {
dseparated(dag, x, y)
} else {
dseparated(dag, x, y, z)
}
}
# Find all d-separating sets
find_dsep_sets <- function(dag, x, y) {
# All adjustment sets that d-separate x and y
adjustmentSets(dag, exposure = x, outcome = y, effect = "total")
}
# Verify conditional independence implications
verify_ci_implications <- function(dag, data) {
implied_ci <- impliedConditionalIndependencies(dag)
results <- lapply(implied_ci, function(ci) {
# Parse the CI statement
vars <- strsplit(as.character(ci), " _\\|\\|_ | \\| ")[[1]]
x <- vars[1]
y <- vars[2]
z <- if (length(vars) > 2) vars[3:length(vars)] else NULL
# Test with partial correlation or conditional independence test
test_result <- test_conditional_independence(data, x, y, z)
list(statement = as.character(ci), p_value = test_result$p.value)
})
do.call(rbind, lapply(results, as.data.frame))
}
A set $Z$ satisfies the backdoor criterion relative to $(A, Y)$ if:
If $Z$ satisfies the backdoor criterion: $$P(Y | do(A = a)) = \sum_z P(Y | A = a, Z = z) P(Z = z)$$
or equivalently: $$E[Y(a)] = E_Z[E[Y | A = a, Z]]$$
When backdoor fails but mediator is unconfounded: $$P(Y | do(A)) = \sum_m P(M = m | A) \sum_{a'} P(Y | M = m, A = a') P(A = a')$$
# Check backdoor criterion
check_backdoor <- function(dag, exposure, outcome, adjustment_set) {
# Using dagitty
valid_sets <- adjustmentSets(dag, exposure = exposure,
outcome = outcome, type = "minimal")
# Check if proposed set is valid
is_valid <- any(sapply(valid_sets, function(s) {
setequal(s, adjustment_set)
}))
list(
is_valid = is_valid,
minimal_sets = valid_sets,
proposed = adjustment_set
)
}
# Compute backdoor-adjusted estimate
backdoor_adjustment <- function(data, outcome, exposure, adjustment) {
formula_str <- paste(outcome, "~", exposure, "+",
paste(adjustment, collapse = " + "))
model <- lm(as.formula(formula_str), data = data)
# Standardization
predictions_a1 <- predict(model,
newdata = transform(data, setNames(list(1), exposure)))
predictions_a0 <- predict(model,
newdata = transform(data, setNames(list(0), exposure)))
list(
ate = mean(predictions_a1 - predictions_a0),
se = sqrt(var(predictions_a1 - predictions_a0) / nrow(data))
)
}
# Full identification analysis
analyze_identification <- function(dag, exposure, outcome) {
list(
adjustment_sets = adjustmentSets(dag, exposure, outcome),
instrumental_sets = instrumentalVariables(dag, exposure, outcome),
direct_effects = adjustmentSets(dag, exposure, outcome, effect = "direct"),
implied_independencies = impliedConditionalIndependencies(dag)
)
}
For most problems, both frameworks give equivalent results: $$E[Y(a)] = E[Y | do(A=a)]$$
Choose based on context and audience.
| Assumption | Formal Statement | Interpretation | |------------|------------------|----------------| | Consistency | $Y = Y(A)$ | Observed outcome equals potential outcome for received treatment | | Positivity | $P(A=a \mid X=x) > 0$ for all $x$ with $P(X=x) > 0$ | Every covariate stratum has both treated and untreated | | Exchangeability | $Y(a) \perp!!!\perp A \mid X$ | No unmeasured confounding given $X$ | | SUTVA | No interference, single version of treatment | Units don't affect each other |
Additional assumptions required:
| Assumption | Formal Statement | Interpretation | |------------|------------------|----------------| | Cross-world exchangeability | $Y(a,m) \perp!!!\perp M(a^*) \mid X$ | Counterfactual mediator independent of counterfactual outcome | | No $A$-$M$ interaction (optional) | $Y(a,m) - Y(a',m)$ constant in $m$ | Simplifies identification | | Compositional | $Y(a) = Y(a, M(a))$ | Potential outcome composition |
Target: $\psi = E[Y(1) - Y(0)]$
Under exchangeability (A1), consistency (A2), positivity (A3):
$$\psi = E\left[E[Y | A=1, X] - E[Y | A=0, X]\right]$$
Proof sketch: \begin{align} E[Y(a)] &= E[E[Y(a) | X]] && \text{(iterated expectations)} \ &= E[E[Y(a) | A=a, X]] && \text{(A1: exchangeability)} \ &= E[E[Y | A=a, X]] && \text{(A2: consistency)} \end{align}
Target: $\psi_{ATT} = E[Y(1) - Y(0) | A=1]$
Under weaker exchangeability $Y(0) \perp!!!\perp A \mid X$:
$$\psi_{ATT} = E\left[E[Y | A=1, X] - E[Y | A=0, X] \mid A=1\right]$$
Target:
Under mediation assumptions (see VanderWeele, 2015):
$$NDE = \int\int {E[Y|A=1,M=m,X=x] - E[Y|A=0,M=m,X=x]} , dP(m|A=0,X=x) , dP(x)$$
$$NIE = \int\int E[Y|A=1,M=m,X=x] {dP(m|A=1,X=x) - dP(m|A=0,X=x)} , dP(x)$$
Target: $CDE(m) = E[Y(1,m) - Y(0,m)]$
Simpler identification (no cross-world assumption):
$$CDE(m) = E[E[Y|A=1,M=m,X] - E[Y|A=0,M=m,X]]$$
A set $X$ satisfies the back-door criterion relative to $(A, Y)$ if:
If satisfied: $$P(Y | do(A=a)) = \sum_x P(Y | A=a, X=x) P(X=x)$$
When there's an unmeasured confounder $U$ between $A$ and $Y$, but $M$ mediates all of $A$'s effect:
U
/ \
↓ ↓
A → M → Y
Identification: $$P(Y | do(A=a)) = \sum_m P(M=m | A=a) \sum_{a'} P(Y | M=m, A=a') P(A=a')$$
When $Z$ affects $Y$ only through $A$:
U
↓
Z → A → Y
Local ATE identification (with monotonicity): $$LATE = \frac{E[Y | Z=1] - E[Y | Z=0]}{E[A | Z=1] - E[A | Z=0]}$$
Product of three path identification requires:
Path-specific effects:
$$\text{Effect through } M_1 \to M_2 = \int E\left[\frac{\partial^3}{\partial a \partial m_1 \partial m_2} E[Y|A,M_1,M_2,X]\right]$$
Expressed as product of coefficients: $\hat{\alpha}_1 \cdot \hat{\beta}_1 \cdot \hat{\gamma}_2$
When point identification fails, we can still bound the parameter.
For ATE with missing outcomes: $$E[Y(1)] \in [E[Y \cdot A]/P(A=1) + y_{min}P(A=0), E[Y \cdot A]/P(A=1) + y_{max}P(A=0)]$$
When exchangeability is uncertain, parameterize violation:
Unmeasured confounding parameter $\Gamma$: $$\frac{1}{\Gamma} \leq \frac{P(A=1|X,U=1)/P(A=0|X,U=1)}{P(A=1|X,U=0)/P(A=0|X,U=0)} \leq \Gamma$$
Compute bounds as function of $\Gamma$ (Rosenbaum bounds).
Minimum strength of unmeasured confounding (on risk ratio scale) needed to explain away observed effect:
$$E\text{-value} = RR + \sqrt{RR \times (RR-1)}$$
| Strategy | Key Assumption | Best For | |----------|----------------|----------| | Regression adjustment | All confounders measured | Rich covariate data | | Propensity score | Correct PS model | High-dimensional confounders | | Instrumental variables | Valid instrument exists | Unmeasured confounding | | Regression discontinuity | Continuity at threshold | Sharp treatment rules | | Difference-in-differences | Parallel trends | Panel data |
\begin{theorem}[Identification of $\psi$]
Under Assumptions:
\begin{enumerate}[label=A\arabic*.]
\item (Consistency) $Y = Y(A)$, $M = M(A)$
\item (Positivity) $P(A=a|X) > \epsilon > 0$ for all $a \in \mathcal{A}$
\item (Exchangeability) $Y(a) \perp\!\!\!\perp A \mid X$
\end{enumerate}
the causal estimand $\psi = E[g(Y(a))]$ is identified by
\[
\psi = E_X\left[E[g(Y) \mid A=a, X]\right].
\]
\end{theorem}
\begin{proof}
\begin{align}
E[g(Y(a))] &= E\left[E[g(Y(a)) \mid X]\right]
&& \text{(law of total expectation)} \\
&= E\left[E[g(Y(a)) \mid A=a, X]\right]
&& \text{(by A3: exchangeability)} \\
&= E\left[E[g(Y) \mid A=a, X]\right]
&& \text{(by A1: consistency)}
\end{align}
The RHS depends only on the observed data distribution $P(Y,A,X)$.
\end{proof}
A → C ← Y
Conditioning on $C$ opens a path between $A$ and $Y$.
A → M → Y
Conditioning on $M$ blocks the indirect effect, doesn't control confounding.
Conditioning on descendants of treatment can bias estimates.
U1 → X ← U2
↓ ↓
A ——————→ Y
Conditioning on $X$ opens path $A \leftarrow U_1 \rightarrow X \leftarrow U_2 \rightarrow Y$.
Interpreting coefficients causally when model includes intermediate variables.
When reviewing identification arguments, ask:
This skill works with:
Imai
Hernan
Pearl, J. (2009). Causality: Models, Reasoning, and Inference (2nd ed.)
VanderWeele, T.J. (2015). Explanation in Causal Inference
Hernán, M.A. & Robins, J.M. (2020). Causal Inference: What If
Imbens, G.W. & Rubin, D.B. (2015). Causal Inference for Statistics
Version: 1.0 Created: 2025-12-08 Domain: Causal Inference, Mediation Analysis
tools
Recommend AND run open-source AI tools, agents, Claude Code / Codex skills, and MCP servers for any stage of a literature review — searching, reading, extracting, synthesizing, screening, citation-checking, and paper writing. Use when the user asks "what tool should I use to..." OR "install/run/use <tool> to ..." for research/lit-review work: automating a survey or related-work section, PDF→Markdown extraction for LLMs (MinerU/marker/docling), PRISMA / systematic review (ASReview), citation-backed Q&A over PDFs (PaperQA2), wiring papers into Claude/Cursor via MCP (arxiv/paper-search/zotero servers), or chatting with a Zotero library. Ships a launcher (scripts/litrun.py) that installs each tool in an isolated venv and runs it. Curated catalog of 70+ vetted projects. 支持中英文(用于「文献综述工具选型」与「一键安装/运行」)。
development
Route empirical-research requests through the Auto-Empirical Research Skills catalog when this whole repository is installed as one skill in Codex, CodeBuddy, Claude Code, or another IDE. Use to choose and load the right vendored AERS skill for causal inference, econometrics, replication, data acquisition, manuscript writing, peer review and referee responses, citation checking, de-AIGC editing, or full empirical-paper workflows without reading the entire repository at once.
documentation
Use when the project collects primary data or runs a field, lab, or survey experiment, before the intervention begins — write the pre-analysis plan, size the sample from a power calculation, and register with the AEA RCT Registry. Apply after the design is chosen in aer-identification and before any outcome data are seen.
tools
Guide economists to authoritative data sources with explicit, confirmed data specifications before retrieval; interfaces with Playwright MCP to navigate portals and extract real data, not articles about data.