Calculate chi-square tests for goodness-of-fit and independence.
The chi-square statistic is calculated as:
Where:
For Independence Test:
Where:
For Goodness-of-Fit Test:
Expected frequencies are either specified or assumed to be equal across all cells.
For Goodness-of-Fit Test:
Where k is the number of categories (cells).
For Independence Test:
Where r is the number of rows and c is the number of columns.