Home Student Resources Chapter 18 – Tests for categorical variables and frequency tables

Chapter 18 – Tests for categorical variables and frequency tables

This chapter discusses the use of the chi-square test to analyze categorical data, and the analysis of multi-way tables using log-linear analysis.

Exercises

Exercise 18.1

A 2 x 2 chi-square analysis

Individual passers-by, approaching a pedestrian crossing, are targeted by observers who record whether the person crosses against the red man under two conditions, when no one at the crossing disobeys the red man and when at least two people disobey. The results are recorded in the table below.

 No jaywalkerAt least two jaywalkers 
Target disobeys light162743
Target obeys light433376
 5960119

1. Calculate the expected frequencies for a chi-square analysis. Copy the table below and enter your results.

 No jaywalkerAt least two jaywalkers 
Target disobeys light  43
Target obeys light  76
 5960119

2. Now conduct the chi-square analysis. The data set is available here. However if you are learning SPSS it is a good idea to set this up for yourself. Don’t forget to weight cases as described on XXX of the book. To weight cases here you need a variable called jaywalkers with two values, ‘none’ and ‘twoplus’. You need a second variable, obeys, with two values ‘no’ and ‘yes’. Make your datasheet show one case for each possible combination and enter the data from the observed data table above into the appropriate rows in a third column variable called count. Then select Data/Weight cases and drop the variable count into the weight cases box to the right.

Now enter your result into the spaces below. In each case use three places of decimals and don’t worry if you’re a fraction out. This could be because of rounding decimals in your calculations.

c2 (1, N = 119) 
p value 
Show answer
 No jaywalkerAt least two jaywalkers 
Target disobeys light21.321.743
Target obeys light37.738.376
 5960119
χ2 (1, N = 119)4.122  
p value.042

Exercise 18.2

A loglinear analysis

Suppose that the research in Exercise 18.1 is extended to include an extra condition of five or more jaywalkers and to include a new variable of gender. The table below gives fictitious data for such an observational study. Conduct a loglinear analysis on the data outlining all significant results in your results report.

Males    
 No jaywalkerAt least two jaywalkersFive or more jaywalkers 
Target disobeys light212538  84
Target obeys light383522  95
 596059179
Females    
 No jaywalkerAt least two jaywalkersFive or more jaywalkers 
Target disobeys light222329  74
Target obeys light393731107
 616060181
Show answer

A three-way backward elimination loglinear analysis was performed on the frequency data in the table above produced by combining frequencies for jaywalkers, obedience and gender. One-way effects were not significant, likelihood ratio χ2 (4) = 5.40, p = .248; two-way effects were significant, likelihood ratio χ2 (5) = 11.968, p = .035; the three-way effect was not significant, χ2 (2) = 1.554, p = .46. Only the jaywalkers x obedience interaction was significant χ2 (2) = 10.845, p = .004. More people crossed against the light when there were more jaywalkers present.

Exercise 18.3

Have a go at this short quiz to test your understanding and identify any gaps in your knowledge.


If you want to use Vassarstats for a chi-square calculation you’ll find it under the ‘Clinical Research Calculators’ tab on the left of the main screen in Vassarstats – see Chapter 17 links.

Using Google you’ll find plenty of chi-square calculators that are easy to use. Here are a few I found:

Chi Square Calculator – Up To 5×5, With Steps (socscistatistics.com)   (deals with up to 5×5 tables).

https://www.mathsisfun.com/data/chi-square-calculator.html – easier to use and deals with up to 10×10 tables.

http://www.quantpsy.org/chisq/chisq

Fischer’s exact test can be done here:

http://graphpad.com/quickcalcs/contingency1.cfm

and on the social science site: Social Science Statistics (socscistatistics.com)