options(repos = c(CRAN = "https://cloud.r-project.org"))
install.packages("readxl")
## Installing package into 'C:/Users/sweth/AppData/Local/R/win-library/4.5'
## (as 'lib' is unspecified)
## package 'readxl' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\sweth\AppData\Local\Temp\Rtmp8Q4y1i\downloaded_packages
library(readxl)
rq1 <- read_excel("C:/Users/sweth/Downloads/RQ1.xlsx")
observed <- table(rq1$Dessert)
print(observed)
##
## Cheesecake ChocoCake Tiramisu
## 171 258 119
names(observed)
## [1] "Cheesecake" "ChocoCake" "Tiramisu"
expected <- c(1/3, 1/3, 1/3)
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
W <- sqrt(chisq_gfit$statistic / sum(observed))
W
## X-squared
## 0.3139217
SUMMARY OF RESULTS
A Chi-Square Goodness-of-Fit Test was conducted to determine whether Dessert preference (Tiramisu, Cheese cake , choco cake) was different from an equal distribution (33.33%, 33.33%, 33.33%) among 548 participants. There was a statistically significant difference in Dessert preferences, χ²(2, N = 548) = 54.004, p = 1.876e-12. Participants preferred Chocolate more than Cheesecake or tiramisu. The effect size was medium (Cohen’s W = 0.3139217).