library(readxl)
A4Q1 <- read_excel("C:/Assignment 4/A4Q1.xlsx")
DatasetName <-
read_excel("C:/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(.348, .296, .228, .128)
chi_result <- chisq.test(x = observed, p = expected)
chi_result
##
## Chi-squared test for given probabilities
##
## data: observed
## X-squared = 78.963, df = 3, p-value < 2.2e-16
w <- sqrt(as.numeric(chi_result$statistic) / sum(observed))
w
## [1] 0.5620065
# A Chi-Square Goodness-of-Fit test was conducted to determine if there was a difference between the observed
# flavor count and the expected flavor count.
# The results showed that there was a difference between the observed and expected frequencies,
# χ²(3) = 78.96, p-value < 2.2e-16 which is 0.00000000000000022.
# The difference was large (Cohen's W = .56).