# Chi-square test: difference between goodness-of-fit test and test of independence

Concerning the Pearson chi-square test there seems to be a subtle difference between the goodness-of-fit test and the test of independence.

What is confusing is that both tests seem to be calculated in a very similar way.

My question: What is the real difference and how to handle that in practice?

(NB: This is question is related, yet not the same: Test of independence vs test of homogeneity)

• Note chisq.test performs one or the other depending on its arguments - read the manual. – Scortchi Mar 31 '14 at 7:31
• @Scortchi: Edited the question accordingly - thank you. – vonjd Mar 31 '14 at 8:25

3) A test of independence tests is for a bivariate** multinomial, of whether $p_{ij}$ is different from $p_{i}\,p_{j}$.