I intend to determine Cramer's $\phi$ for two contingency tables of the following form:
Table 1 (expected empirical)
A B C | sum
95 31 20 | 146
Table 2 (observed empirical)
A B C | sum
70 29 18 | 117
Cramer's $\phi = \sqrt{\frac{\chi^2}{n\cdot(\min(r,~c)-1)}}$. Here, $n$ is the total number of observations, $r$ is the number of rows, and $c $ the number of columns. The value $\chi^2$ is the sum of quadratic differences between expectation and observation, normalized by the expected value. As I understand it, however, there are two ways of determining $\chi^2$ of two tables. (Note that I am aware of the conditions that need to apply for calculating $\chi^2$. Please ignore the fact that some conditions might be violated in the examples.)
On the one hand, you can determine $\chi^2$ by calculating the probabilities from one of the tables and use them to predict the number of observations in each category of the other table, given its total number of observations.
Assuming Table 1
gives the expected values and Table 2
describes the observations, observation probabilities rounded to two decimals would look like this.
Table 1a (expected theoretical)
A B C
0.65 0.21 0.14
By multiplying each probability with the row sum of the observed values in Table 2
we get the following expected empirical observations.
Table 2a (expected empirical, fitted)
A B C | sum
76.05 24.57 16.38 | 117
With Table 2a
$\chi^2 = \frac{(70-76.05)^2}{76.05} + \frac{(29-24.57)^2}{24.57} + \frac{(18-16.38)^2}{16.38} = 0.48 + 0.80 + 0.16 = 1.44$.
On the other hand, you can determine $\chi^2$ by combining the two tables to perform a homogeneity test.
Table 3
A B C | sum
(1) 95 31 20 | 146
(2) 70 29 18 | 117
sum 165 60 38 | 263
Here you get the expected values by multiplying the respective column and row sums and dividing the product with the total number of observations. As an example, for cell (1, A)
this is $146 \cdot 165 / 263 = 91.60$.
Table 3a
A B C
(1) 91.60 33.31 21.10
(2) 73.40 26.70 16.90
With Table 3a
$\chi^2 = \frac{(95-91.60)^2}{91.60} + \frac{(31-33.31)^2}{33.31} + \frac{(20-21.10)^2}{21.10} + \frac{(70-73.40)^2}{73.40} + \frac{(29-26.70)^2}{26.70} + \frac{(18-16.90)^2}{16.90}$
$\chi^2 = 0.13 + 0.16 + 0.06 + 0.16 + 0.20 + 0.07 = 0.78$
Which $\chi^2 $-value is the right one for Cramer's $\phi$? If the first method is correct, do I take $n$ from the observed or from the expected values? If the second method is correct, how would I generate Table 3
and Table 3a
from multidimensional data?