Chi-Square Goodness-of-Fit Test

Load Packages

library(readxl)

Import Data

A5Q1 <- read_excel("C:/Users/wmacklin/Downloads/A5Q1-1.xlsx")

View(A5Q1)

Observed Counts

table(A5Q1$flavor)
## 
##  Chocolate      Mango Strawberry    Vanilla 
##         87         32         57         74

Barplot of Ice Cream Purchases

barplot(
  table(A5Q1$flavor),
  main = "Ice Cream Purchases by Flavor",
  xlab = "Flavor",
  ylab = "Number of Purchases"
)

Chi-Square Goodness-of-Fit Test

chisq.test(
  table(A5Q1$flavor),
  p = c(0.20, 0.20, 0.20, 0.40)
)
## 
##  Chi-squared test for given probabilities
## 
## data:  table(A5Q1$flavor)
## X-squared = 41.6, df = 3, p-value = 4.878e-09

Interpretation

The chi-square goodness-of-fit test was statistically significant, χ²(3) = 41.60, p < .001. This indicates that ice cream purchases were not distributed according to the expected proportions. The observed purchasing frequencies differed significantly from the expected distribution, suggesting that some flavors were preferred more than others.