Sunday, 11 March 2018

Question 13 - Chi-Square Test for Independence Step by Step Procedure(Political Affilication...)

Question 13
A random sample 500 U.S adults are questioned about their political affiliation and opinion on a tax reform bill. We need to test if the political affiliation and their opinon on a tax reform bill are dependent, at 5% level of significance. The observed contingency table is given below.


Get the excel file used for this exercise

Solution Steps
As usual, we need to understand the question. Here there are three groups of respondents. The interesting thing about chi-square is that the formular is consistent and is given by:

Now we are going to transfer this data to excel. Take note of how this is done. I have created a second table we would use to do the computation

Tables 1

Step 1: State the null and alternate hypothesis
H0: The groups are independent
Ha: The values are not dependent

Step 2: Calculate the Expected Values
The expected values in this case is calculated like this:
For each cell, multiply the row sub-total  by the column sub-total and divide by the grand total (which is 500 in this cas)
For example, in the first cell under the favor column and in the democrat row, the expected value would be given as:

If you do this for all the cells, we would have the completed table as shown below. The second table now contains the expected values

Tables 2

Step 3: Calculate the Deviations from the Expected Values 
Step 4: Calculate the Squared Deviations
Step 4 follows from step 3.
This you can simply do by subtracting the expected values in the second table from the observations in table.
For example, for the first cell, we have the calculation

I have done it for all the cells and the tables below illustrates the results in the table of Squared Deviations

Tables 3

Step 5: Divide by the expected values
In this step, you simply divide the values of the squared deviations with the corresponding values of the in the Expected Values table.
After doing this you will have the results in Tables 4:

Tables 5

Step 6: Calculate the Chi-Square Statitic
You can easily find this value by taking the sum all the values(except the totals) in the 4th table.
Chi-Square test statistic = 22.152

Step 7: Look up Statistical Table for the p-Value
You can find te p-value using the calculate chi-square statistic and the degrees of freedom

Degrees of freedom is given by N-1 (N is the number of groups. Here there are 3 groups)
df = 3 - 1 = 11
where N is the number of observation. In this case
See statistical tables here

From the chi-square table we get a p-value of  5.991

Step 8: State the Conclustion
In this case we can see that the calculated value of the test statistic is larger than the critical value. Therefore, we reject the null hypothesis and conclude that there is significant independence between the groups of observations.

Get this excel file