Module 5 — Two categorical variables

Question: is hypertension more common among smokers? Two categorical variables → a crosstab, and the chi-square test of independence.

Open the sample (Ctrl+Shift+O).

The crosstab

Analyze → Descriptive Statistics → Crosstabs… Rows SmokingStatus, columns Hypertensive, tick Chi-square, Run.

Read the table before the test: within each smoking row, what fraction is hypertensive? Percentages, not raw counts, carry the comparison — the row groups have different sizes.

The chi-square test

Below the table, the chi-square block tests independence: "if smoking and hypertension were unrelated, how surprising would this table be?" A small p ("Asymp. Sig.") — conventionally under .05 — says the pattern is unlikely to be chance. With this dataset's planted effect (codebook), expect a clearly significant result.

Two cautions that belong in every report:

  • Chi-square says the variables are associated, not why — this is observational data, and "smoking causes hypertension here" is a claim the design cannot make.
  • The test needs adequate expected counts per cell; with very sparse tables, collapse categories or use an exact test (Analyze → Nonparametric Tests).

Exercise

  1. FamilyHistoryDM × Diabetic, with chi-square. Association?
  2. StudyZone × Hypertensive. The codebook plants no zone effect — what does an honestly non-significant chi-square look like, and how would you report it?
  3. Re-run step 1 split by sex: Data → Split File…, split by Sex, run the crosstab, then turn Split File off. Does the association hold in both groups?

The syntax trail

crosstabs row=SmokingStatus, column=Hypertensive, chi_square=true
crosstabs row=FamilyHistoryDM, column=Diabetic, chi_square=true