Chi Square Test of Independence This is a contingency table.
Also called a 2-way table, cross classification table,
cross tabulation or just crosstab.
It shows the observed number of cases or frequency for two categorical variables.
By Categorical, we mean nominal or ordinal.
These variables are ordinal since their categories can be ranked.
The row variable is Age Category consisting of 4 categories.
The column variable is AI usage consisting of 3 categories.
We refer to a table with this structure as a 4 x 3 contingency table
because it has 4 rows and 3 columns.
The Chi square test of independence is often employed to determine if a significant association
or relationship exists between two categorical variables.
Note that we are not testing for a correlation.
That term “correlation” is reserved for the relationship between two quantitative
variables.
Let’s begin with this 3x2 contingency table.
That is, we have 3 rows and 2 columns.
Suppose we want to test if there is a relationship or association between age category and AI
usage.
Then the null hypothesis will be that there is no relationship between the two variables.
In essence, Age and AI usage are independent.
The alternative hypothesis will be that there is a relationship.
That is, Age and AI usage are dependent.
In the null hypothesis, Independence there means that there is no difference in the distribution
of AI usage among the age categories.
In the alternative hypothesis, dependence or relationship implies that AI usage distribution
will differ among the age categories.
Specifically, the question here is, are some age categories likely to use AI more than
others?
The test statistic for chi square test of independence is the same as the one used for
the Goodness of fit test …in that, it compares observed frequencies
with expected frequencies.
The null hypothesis here basically says that the observed and expected frequencies for
each cell are essentially equal while the alternative states that they are
different.
Here again is our 2-way table showing rows and column totals.
The expected frequencies are calculated on the assumption that the two variables are
independent.
As a result, the formula for calculating the expected values for each cell turns out to
be Row total x column total, divided by sample
size n (or grand total) which is 1440 in this case.
I’m going to place the expected frequencies in this table on the right here.
For the “Under 30” and “Yes” cell, the row total is 490 and the column total
is 809 so the expected value is calculated as 490
* 809/ 1440.
And that gives 275.28.
For the expected value for the “Under 30” and “No” cell,
the row total is 490 times 631, the column total,
and divided by the grand total of 1440.
For row 2 column 1, we have 456*809 divided by 1440 which gives 256.18.
We continue in that fashion for the row 2 column 2
Row 3 column 1 And row 3 column 2.
Now, when we compute the expected totals, note that they must equal the observed totals
except for rounding errors.
Note that each expected cell must have a value of at least 5 for the test to be valid.
However, some authors only require that no more than 20% of the expected cells should
be less than 5.
Let’s now compute the value of the chi-square statistic for the problem.
For the first cell, we take the observed (312) minus the expected (275.28),
square the result, and divide by the expected.
We do the same for the 178, the 273,
the 183, the 224,
and the 270.
On computing these, we have an observed chi square value of 37.26.
Now back to the hypothesis test.
The degrees of freedom for the chi square test of independence is
(number of rows – 1) times (number of columns – 1)
Since we have 3 rows and 2 columns, the degrees of freedom computes to a value of 2.
Now, suppose we’re testing at the significance level alpha of 0.05,
we can obtain the critical chi square value for the test by using software or from the
chi square table.
With df = 2 and alpha = 0.05, we have a critical value of 5.99.
In essence, we will reject the null hypothesis and say that the result is significant if
our computed chi square statistic is greater than 5.99.
Since our chi square stat is 37.26, which is greater than 5.99,
we will reject the null hypothesis and conclude that Age and AI usage are dependent.
In other words, there is significant association, or the distribution of AI usage is different
among the age categories.
We can calculate the P-value of the test using software.
or estimate it from the chi square table.
Going again to df = 2 in the table, we find that the chi square statistic of 37.26 is
larger than all critical values listed there.
We therefore say that the P-value is less than .005, or whatever the smallest alpha
listed is.
Now, suppose the test statistic were 8.33, then the P-value will lie between .01 and
.025.
Recall that we reject the null hypothesis if P-value is less than alpha.
Since this P-value is still less than .05, the result is still significant,
and we still reject the null hypothesis.
The test statistic is also greater than the critical value
corroborating the decision to reject the null hypothesis.
However, if the observed chi square were 4.84, the P-value will lie between 0.1 and 0.05,
and the association is no longer significant or we fail to reject the null hypothesis),
since the P-value is now greater than 0.05, or because the test statistic is no longer
greater than the critical value.
Therefore, we don’t have enough evidence to conclude that Age and AI usage are dependent
in this case.
And that’s it for this video.
Thanks for watching.