What is the difference between chi square goodness of fit and independence test?

statistics

#1

Hi,
I have been studying about the use of chi-square to determine relationship between categorical data sets.
I am confused about when to use Goodness of fit test and Independence test.
Thanks


#2

Independence Test:
This is used when we want to know if the output is dependent on some suspected variable.
Say we want to know whether brand preference depends on age or not.
Observed Result
Expected Result
On calculating the p-value using the Chi-Sq function we get a value of 82%,which shows that brand preference is independent of age.

Goodness of fit:This is generally used when we want to test whether the data follows a particular distribution or not.
We want to know whether a dice is fair or not.If a dice is fair it’s output will follow a binomial distribution.
Say,we are recording the number of 6’s in 3 rolls of a dice,repeated 100 times.

The probabilities are calculated using binomial distribution function.
Next the p-value is calculated using the Chi-Sq distribution,it comes out to be = 1.59457230734393E-005
Since this is less than 5% we reject the H0: Dice is fair.
Hope this helps!!