Suppose a causal DAG says education should provide no additional information about a person’s preferred transport once occupation and residence are known. A statistical independence test checks that claim against observed data. More generally, causal relationships imply independence or conditional independence constraints; finding strong evidence of dependence where a DAG predicts independence can refute the DAG. section 4.1 section 4.3.2
Write conditional independence as X ⊥ Y | Z. In a conventional test, the null hypothesis is that X and Y are independent given Z; the alternative is that they are dependent. A test statistic measures association, while its p-value measures how likely an association at least that strong would be if the null were true. Below a chosen significance threshold, the test favors dependence. Above it, the test does not establish independence: sampled data can mislead in either direction. section 2.3.3 section 4.3.2 section 4.4.1 section 4.4.3
Test a transportation DAG
Let E be education, T preferred transport, O occupation, and R residence. The DAG predicts E ⊥ T | O, R. With observations of all four variables in a pandas DataFrame, run pgmpy’s chi_square with X="E", Y="T", Z=["O", "R"], and a significance level such as .05. Request the statistic and p-value for inspection, or a Boolean result when checking many assertions generated from the DAG’s d-separations. A 30-row test of this relation produced p = 0.56; that result alone does not prove the DAG correct. section 4.3.2 section 4.4.3
Listing 4.4 Chi-squared test of conditional independence
from pgmpy.estimators.CITests import chi_square #1
significance = .05 #2
result = chi_square( #3
X="E", Y="T", Z=["O", "R"], #3
data=data, #3
boolean=False, #3
significance_level=significance #3
) #3
print(result)
The chi-squared test call shows how to map a DAG’s proposed conditional independence onto observed columns, conditioning variables, and a significance level. section 4.3.2
Use the result as a model check, not a verdict:
- Expect both false conclusions of dependence and false conclusions of independence; tests see samples, not the underlying joint distribution. section 4.4.1
- Check sensitivity to sample size. In the simulated transportation example, bootstrap analysis shows p-values falling as sample size grows, eventually favoring rejection of a true independence claim. section 4.4.3
- Treat conventional tests as a heuristic for DAG refutation: their independence null is poorly aligned with the aim of gathering affirmative evidence for a proposed model. section 4.4.2
- For multidimensional or nonlinear variables, consider more flexible tests or compare predictions of Y from Z against predictions from X and Z; guard the comparison against overfitting. section 4.4.5
A practical workflow is to test independence claims implied by d-separation, revise a DAG when compelling dependence contradicts it, and continue toward the causal question. When data types complicate testing, discretizing a continuous variable and using a chi-squared test may be a sufficient working approach rather than building an elaborate test suite. section 4.0 section 4.4.6

