HYPOTHESES

H0:The observed frequencies matches the expected frequencies.

H1:The observed frequencies do not match the expected frequencies

INSTALL AND LOAD REQUIRED PACKAGE

# install.packages("readxl")
library(readxl)

IMPORT THE EXCEL FILE

dataset <- read_excel("C:/Users/konifade/Downloads/RQ1.xlsx")

CREATE AND VIEW YOUR FREQUENCY TABLE

observed <- table(dataset$Dessert)
print(observed)
## 
## Cheesecake  ChocoCake   Tiramisu 
##        171        258        119

EXPECTED PROPORTIONS

expected <- c(1/3, 1/3, 1/3)

CALCULATE CHI-SQUARED RESULTS

chisq_gfit <- chisq.test(observed, p = expected)

print(chisq_gfit)
## 
##  Chi-squared test for given probabilities
## 
## data:  observed
## X-squared = 54.004, df = 2, p-value = 1.876e-12

EFFECT SIZE

W <- sqrt(chisq_gfit$statistic / sum(observed))
 W
## X-squared 
## 0.3139217

COMMENT

A Cohen’s W of 0.314 indicates a moderate difference between the observed and expected frequencies, reflecting a moderate effect size.

BAR PLOT

barplot(rbind(observed, expected * sum(observed)),
         beside = TRUE,
         col = c("skyblue", "orange"),
         names.arg = names(observed),
         legend.text = c("Observed", "Expected"),
         main = "Dessert Preferences: Observed vs Expected")

FINAL REPORT

A Chi-Square Goodness-of-Fit Test was conducted to determine whether dessert type preference (Cheesecake, ChocoCake , Tiramisu) was different from an equal distribution (33.33%, 33.33%, 33.33%) among 548 participants. There was a statistically significant difference in dessert type preferences, χ²(2, N = 548) = 54.004, p < .001. Participants preferred chococake more than cheesecake or tiramisu. The effect size was medium (Cohen’s W = 0.314).