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

expected <- c(.2, .2, .2, .4)
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
#A Chi-Square Goodness-of-Fit test was conducted to determine if there was a difference between the sales distribution of Ice Cream in the month of August last year and the sales this year.
#The results showed that there was a difference between the observed and expected frequencies, χ²(2) = 41.6, p = 4.878e-09. Effect size is calculated.
#The difference was moderate, (Cohen's W = .40).