How to create contingency.tables and calculate Chi Square in Excel

advertisement
How to create a contingency table using Excel:
1. Highlight the columns of observations that you want to use for your
contingency table from your datasheet.
2. Go to the “Data” tab and click on Pivot Table.
3. A set-up wizard window will open—select the default for the first two
screens, but on the third you will see a box that says “Layout”. Click on
“Layout”.
4. You should now see a contingency table shell with a listing of all the variables
you selected for analysis.
5. Drag the (predictor) independent variable of interest over to the row box.
6. Drag the (outcome) dependent variable of interest over to the column box.
7. Drag the (outcome) dependent variable of interest over to the data box, as
well.
8. Click “OK”.
9. In the constructed contingency table, remove black values by clicking on the
variable name in the contingency table and highlighting “blank”—click OK to
remove the blank categories.
How to use Excel to calculate expected frequency tables from contingency
tables:
1. The expected value is equal to (Row total)*(Column total)/Grand Total.
2. For example, consider the above contingency table constructed in excel. To
calculate the expected frequency for happy=1 and trust=1, we would type:
=(814*759)/2504. And for happy=2 and trust=1, we would type:
=(814*1401)/2404
3. Do this for each cell with data to get all the expected counts.
How to use Excel to calculate chi-square tests from contingency tables:
1. Select “Insert”.
2. Go to “Function” and select “Statistical CHITEST”.
3. In the actual data location window, highlight the cells in the excel sheet that have
all the observed data.
4. In the expected data location window, highlight the cells in the excel sheet that
have all the expected data.
5. In the CHITEST function window, the p value will appear next to the “Result”.
6. To get the actual test statistic for the CHITEST, highlight the p value obtained
from CHITEST, in a new cell in excel type in =CHIINV([pasted p value], [df]) where
you are pasting in the p value obtained from CHITEST and df=typing in the degrees
of freedom. (Note: if the p value is very, very small, simply type out 0.00001,
otherwise you will likely get an error.)
Download