Research Question

Is the distribution of this year’s August ice-cream purchases different from last year’s expected distribution of 20% chocolate, 20% strawberry, 20% mango, and 40% vanilla?

library(readxl)

A4Q1 <- read_excel("C:/Users/nehab/OneDrive/A5221/Assignment 4/A4Q1.xlsx")

observed <- table(A4Q1$flavor)
observed
## 
##  Chocolate      Mango Strawberry    Vanilla 
##         87         32         57         74
barplot(
  observed,
  main = "Ice Cream Purchases",
  xlab = "Ice Cream Flavor",
  ylab = "Count",
  col = rainbow(length(observed))
)

expected <- c(.20, .20, .20, .40)

chi_result <- chisq.test(x = observed, p = expected)
chi_result
## 
##  Chi-squared test for given probabilities
## 
## data:  observed
## X-squared = 41.6, df = 3, p-value = 4.878e-09
w <- sqrt(as.numeric(chi_result$statistic) / sum(observed))
w
## [1] 0.4079216
# I updated the interpretation of the effect size.
# My original answer reported Cohen's W = .41 but did not explain that it was moderate.

Interpretation

A Chi-Square Goodness of Fit test showed that the distribution of this year’s ice-cream purchases was significantly different from last year’s expected distribution, X-squared(3, N = 250) = 41.60, p < .001. The difference was moderate, Cohen’s W = .41.