From the given contingency table, test whether gender and ice-cream flavor preference are associated.
# Frequencies read from the question image
tbl <- matrix(
c(100, 120, 60,
350, 320, 150),
nrow = 2,
byrow = TRUE,
dimnames = list(
Gender = c("Men", "Women"),
Flavor = c("Chocolate", "Vanilla", "Strawberry")
)
)
tbl
## Flavor
## Gender Chocolate Vanilla Strawberry
## Men 100 120 60
## Women 350 320 150
sum(tbl) # Table total (image text mentions 920, but tabulated counts sum to 1100)
## [1] 1100
chi_result <- chisq.test(tbl, correct = FALSE)
chi_result
##
## Pearson's Chi-squared test
##
## data: tbl
## X-squared = 4.3195, df = 2, p-value = 0.1154
chi_result$expected
## Flavor
## Gender Chocolate Vanilla Strawberry
## Men 114.5455 112 53.45455
## Women 335.4545 328 156.54545
min(chi_result$expected)
## [1] 53.45455
if (chi_result$p.value < alpha) {
cat("Decision: Reject H0 at 5% significance level.\n")
cat("Conclusion: There is a significant association between gender and flavor preference.")
} else {
cat("Decision: Fail to reject H0 at 5% significance level.\n")
cat("Conclusion: No significant association is detected between gender and flavor preference.")
}
## Decision: Fail to reject H0 at 5% significance level.
## Conclusion: No significant association is detected between gender and flavor preference.