library(readxl)
A4Q1 <- read_excel("C:/Users/giuli/OneDrive - Saint Louis University/AA 5221/Assignment 4/A4Q1.xlsx")
table(A4Q1$flavor)
##
## Chocolate Mango Strawberry Vanilla
## 87 32 57 74
observed <- table(A4Q1$flavor)
observed
##
## Chocolate Mango Strawberry Vanilla
## 87 32 57 74
barplot(observed,
main = "flavor",
xlab = "flavor",
ylab = "Count",
col = rainbow(length(observed)))

expected <- c(0.35, 0.29, 0.23, 0.13)
chi_result <- chisq.test(x = observed, p = expected)
chi_result
##
## Chi-squared test for given probabilities
##
## data: observed
## X-squared = 75.624, df = 3, p-value = 2.663e-16
w <- sqrt(as.numeric(chi_result$statistic) / sum(observed))
w
## [1] 0.5499951
# A Chi-Square Goodness-of-Fit test was conducted to determine if there was a difference between the observed flavor frequencies and the expected frequencies.
# The results showed that there was a difference between the observed and expected frequencies, χ²(df) = 75.62, p = 2.66e-16.
# The difference was large (Cohen's W = 0.55).