In: Math
Chi Square Test
We will now use Excel to run an example of a chi square test.
Chi square test is checking the independence of two variables. Our
example will test if taking hormonal pills and being overweight are
related. We will test the independence on 200 random patients.
Thus, N=200. They will be divided first into two groups, those who
take hormonal pills and those who do not. Second, they will be
divided into three groups based on weight, not overweight,
overweight and obese. All data is in this table
Observed frequency table Not overweight
overweight obese total
Not taking hormonal pills 35 36 49
120
Take hormonal pills 33 32 15 80
Total 68 68 64 200
We will start in Excel by making the above table in region
A1-E4, first five columns and first four rows. That is, in celll B1
you will type Not overweight, in cell A2 Not taking hormonal pills,
etc
Next we construct the expected table. Let's make it in the region
A8-E11. Type Expected frequency table in cell A8, not overweight in
cell B8 etc. Data in the table is calculated in this fashion. Cell
B10 corresponds to the take hormonal pills row and not overweight
column. Thus in cell B10 we type =B4*E3/E4. In cell D10 we type
=D4*E3/E4. Using that strategy complete the expected frequency
table.
Next we check if chi square test will work for this example. When
you remove total from the expected frequency table, you have a 2x3
table with 6 entries. To run chi square we should first have no
zero entries out of those 6. In cell A13 type zero entries. In cell
B13 type the actual value of how many zero entries you have in
expected frequency table. Second, you should have at most 20%
entries that are less than 5. In cell A14 type percentage of
entries less than 5. In cell B14 calculate the actual value of
percents of entries in expected frequency table that are less than
5.
Now let's evaluate chi square parameters. In cell A16 type df. In
cell B16 evaluate df. In cell A20 type chi square. We will evaluate
chi square in cell B20. In cell B20 type
=(B2-B9)^2/B9+(B3-B10)^2/B10+(C2-C9)^2/C9+(C3-C10)^2/C10+(D2-D9)^2/D9+(D3-D10)^2/D10.
In cell A22 type table chi square and then find the table value on
page 416 with .05 level of significance and degrees of freedom df
from B16. Put that value in cell B22.
Now we do testing. In cell A24 type H0 and in cell B24 state the
null hypothesis. In cell A25 type H1 and in cell B25 state the
alternate hypothesis.
Now compare the values in cells B20 and B22. State if we reject or
do not reject the null hypothesis in cell A26. Explain how you
obtained your conclusion in cell B26.
Next we will test it another way, with asymptotic significance
(probability).
In cell A28 type Asymp. Sig. (probability). We will evaluate Sig.
in cell B28. We will use an Excel command for finding sig. in a chi
square test. In cell B28 type =CHITEST(B2:D3,B9:D10).
Compare the sig. in cell B28 with the significance level of .05 and
using that comparison, state in cell A31 if we reject or do not
reject the null hypothesis. Explain how you have reached your
statement in cell B31.
Detailed solution with formulas in excel has been provided.
Explanation solution
Excel formula solution