Correspondence analysis (source code)

= Correspondence analysis

<Correspondence analysis> represents a nonnegative contingency table geometrically, displaying how row and column profiles depart from <independence>. Let $P$ be the table divided by its grand total, and let $r=P\mathbf1$, $c=P^T\mathbf1$ be positive marginal proportions. Its standardized residual <matrix> is
$$
S=D_r^{-1/2}(P-rc^T)D_c^{-1/2}.
$$
A <singular value decomposition> of $S$ provides principal axes; the sum of squared singular values equals the Pearson <Pearson chi-squared statistic for contingency tables> divided by the grand total. Thus weighted departures from <independence> become geometric variation.<Geometric Data Analysis by Brigitte Le Roux and Henry Rouanet>[Chapter 2, correspondence analysis]{ref}

For counts $\begin{pmatrix}30&10\\10&30\end{pmatrix}$, the total is 80 and both margins are $(1/2,1/2)$. Then $S=\begin{pmatrix}1/4&-1/4\\-1/4&1/4\end{pmatrix}$ has one nonzero singular value $1/2$. The total inertia is therefore $1/4$ and the <Pearson chi-squared statistic for contingency tables> is 20. The association has one geometric dimension. Zero margins require removal or separate treatment before using the inverse square roots.