liveBook · Manning

Chi-squared distribution

As explained in Causal AI

A chi-squared distribution is a continuous probability distribution commonly associated with sums of squared standard normal variables and categorical test statistics.

The chi-squared distribution supplies a reference model for a test statistic when evaluating conditional independence. A library uses that assumption to calculate a p-value, then compares the p-value with a significance threshold such as 0.05. A higher p-value favors the null hypothesis of conditional independence; it does not establish the causal model as true. section 4.3.2

A practical conditional-independence workflow is:

  • Specify variables X and Y, conditioning variables Z, observed data, and a significance level. section 4.3.2
  • Run pgmpy’s chi_square test and inspect the chi-squared statistic, p-value, and degrees of freedom. section 4.3.2
  • Repeat the test across d-separation statements and count the proportion that fail to support conditional independence. section 4.3.2

Transportation survey

Testing education and transportation while conditioning on occupation and residence returns a chi-squared statistic of 1.1611, p-value 0.5596, and 2 degrees of freedom. With significance 0.05, the Boolean result favors conditional independence. section 4.3.2

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)

Shows the Python call that applies the chi-squared conditional-independence test. section 4.3.2

How Causal AI covers it

How deep it goes
Explains p-value decisions and returned statistics, but defers the distribution’s mathematical derivation.
Examples
Uses transportation-survey variables, a pgmpy test call, and repeated tests of graph-derived d-separation statements.
What it assumes
Assumes familiarity with p-values, significance thresholds, conditional independence, and causal graphs.
What you can do after
Apply it via pgmpy to evaluate conditional-independence claims and summarize failures across d-separation tests.
How it connects
Connects conditional independence, p-values, significance levels, degrees of freedom, d-separation, and causal graphs.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Causal AI. The section links point to the parts of the book it draws on.