data(HairEyeColor)
str(HairEyeColor)
'table' num [1:4, 1:4, 1:2] 32 53 10 3 11 50 10 30 10 25 ...
- attr(*, "dimnames")=List of 3
..$ Hair: chr [1:4] "Black" "Brown" "Red" "Blond"
..$ Eye : chr [1:4] "Brown" "Blue" "Hazel" "Green"
..$ Sex : chr [1:2] "Male" "Female"
HairEyeColor
, , Sex = Male
Eye
Hair Brown Blue Hazel Green
Black 32 11 10 3
Brown 53 50 25 15
Red 10 10 7 7
Blond 3 30 5 8
, , Sex = Female
Eye
Hair Brown Blue Hazel Green
Black 36 9 5 2
Brown 66 34 29 14
Red 16 7 7 7
Blond 4 64 5 8
summary(HairEyeColor)
Number of cases in table: 592
Number of factors: 3
Test for independence of all factors:
Chisq = 164.92, df = 24, p-value = 5.321e-23
Chi-squared approximation may be incorrect
Null Hypothesis (H₀): The three factors (hair color, eye color, and sex) are independent of each other
Meaning: Hair color doesn’t affect eye color, sex doesn’t affect hair/eye color combinations, etc.
Alternative Hypothesis (H₁): The factors are NOT independent (they are associated)
Chi-square statistic (164.92):
This measures how much the observed counts differ from what we’d expect if the factors were independent
Larger values indicate stronger evidence against independence
Degrees of freedom (24):
Calculated as: (4 hair colors - 1) × (4 eye colors - 1) × (2 sexes - 1) = 3 × 3 × 1 = 24
This represents the number of “free” pieces of information in the analysis
Extremely small p-value (5.321 × 10⁻²³):
This is 0.0000000000000000000005321
Far below the typical significance level of 0.05