I want to compare two contingency tables A and B with the same structure (same columns and rows). My first idea was to use chi squared distance $\sum_{i=1}^{p}{\frac{(O_i-E_i)^2}{E_i}}$. But, some cells $E_i$ are equal to zero.
Have you some ideas to deal with that problem or another distance metrics without this issue ?
More precisely, let's consider the contingency table A:
Atoms | Carbone | Hydrogen | Nitrogen |
---|---|---|---|
Carbone | 2339 | 2582 | 305 |
Hydrogen | 2582 | 0 | 144 |
Nitrogen | 305 | 144 | 29 |
Each cell $A_{ij}$ of table A shows how many times the two atoms (corresponding to the row i and the column j) are linked together to form a molecule in our data (in molecule table of the Biodegradability database).
I have another list of molecules who is represented by the contingency table B: Given another contingency table B:
Atoms | Carbone | Hydrogen | Nitrogen |
---|---|---|---|
Carbone | 1293 | 2664 | 107 |
Hydrogen | 2664 | 1310 | 114 |
Nitrogen | 107 | 114 | 0 |
My objective is to measure how close the table B is from table A by computing the chi-squared distance. As we can see, if we directly compute this distance, we get infinite value because of the null value in the cell B(Nitrogen, Nitrogen) -- Nitrogen atoms are never linked together in table B.
Do you have any idea on how to deal with this issue or have any other distance metric (without this issue) to propose?