Hypotheses
H0 (Null Hypotheses): The observed frequencies matches the expected frequencies. H1 (Alternate Hypotheses): The observed frequencies does not match the expected frequencies.
Result
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) = 9.67, p < .001.Participants preferred ChocoCake more than Cheesecake or tiramisu. The effect size was moderate (Cohen’s W = 0.31).
R Code
INSTALL REQUIRED PACKAGE The package only needs to be installed once. The code for this task is provided below. Remove the hashtag below to convert the note into code.
LOAD THE PACKAGE You must always reload the package you want to use. The code for this task is provided below. Remove the hashtag below to convert the note into code.
library(readxl)
IMPORT THE EXCEL FILE INTO R STUDIO
dataset <- read_excel("C:/Users/hites/Downloads/RQ1.xlsx")
VISUALLY DISPLAY THE DATA
CREATE A FREQUENCY TABE
observed <- table(dataset$Dessert)
VIEW YOUR FREQUENCY TABLE
print(observed)
##
## Cheesecake ChocoCake Tiramisu
## 171 258 119
names(observed)
## [1] "Cheesecake" "ChocoCake" "Tiramisu"
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
W <- sqrt(chisq_gfit$statistic / sum(observed))
W
## X-squared
## 0.3139217