Research Scenario 1:

A restaurant sells three kinds of desserts: chocolate cake, vanilla cheesecake, and tiramisu. If all three desserts are selling equally, then the restaurant owner will keep all three desserts on the menu. However, if some desserts are less popular than others, she would like to remove those items so she can increase her profits. Analyze the data from the restaurant to determine if the actual distribution of the dessert preference matches the expected distribution.

Test for the research question:

CHI-SQUARE GOODNESS OF FIT

HYPOTHESES

NULL HYPOTHESES

The observed frequencies matches the expected frequencies.

ALTERNATE HYPOTHESIS

The observed frequencies does not match the expected frequencies.

QUESTION

What are the null and alternate hypotheses for your research?

H0: The three desserts are equally distributed H1: The three desserts are not equally distributed

IMPORT EXCEL FILE CODE

PURPOSE OF THIS CODE

Imports your Excel dataset automatically into R Studio. You need to import your dataset every time you want to analyze your data in R Studio.

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.

options(repos = c(CRAN = "https://cloud.r-project.org"))
install.packages("readxl")
## Installing package into 'C:/Users/Murari_Lakshman/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\Murari_Lakshman\AppData\Local\Temp\RtmpgN0ptx\downloaded_packages

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)
## Warning: package 'readxl' was built under R version 4.5.2

IMPORT THE EXCEL FILE INTO R STUDIO

Download the Excel file from One Drive and save it to your desktop. Right-click the Excel file and click “Copy as path” from the menu. In R Studio, replace the example path below with your actual path.

rq1 <- read_excel("C:/Users/Murari_Lakshman/Downloads/RQ1.xlsx")

VISUALLY DISPLAY THE DATA

PURPOSE

Visually display the data. A frequency table can be used instead of a bar graph to visually display the data.

CREATE A FREQUENCY TABE

Replace “dataset” with the name of your dataset (without the .xlsx) Replace “Variable” with the R code name of your variable Remove the hashtag to use the code. The code for this task is provided below. Remove the hashtag below to convert the note into code.

observed <- table(rq1$Dessert)

VIEW YOUR FREQUENCY TABLE

View the observed frequencies. The code for this task is provided below. Remove the hashtag below to convert the note into code.

print(observed)
## 
## Cheesecake  ChocoCake   Tiramisu 
##        171        258        119

VIEW THE CATEGORY ORDER

The code for this task is provided below. Remove the hashtag below to convert the note into code.

names(observed)
## [1] "Cheesecake" "ChocoCake"  "Tiramisu"

CHI-SQUARE GOODNESS OF FIT CODE

PURPOSE

Determine if the null or alternate hypothesis was supported.

DEFINE EXPECTED PROPORTIONS

First, look at your methods/ research design to determine the expected proportions for each category. Next, turn those proportions into decimals. The expected proportions MUST be in the same order as the categories. Percentages should be written as decimals (e.g., 0.30 = 30%) and add up to 1

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

DETERMINE STATISTICAL SIGNIFICANCE If results were statistically significant (p < .05), continue to the effect size section below. If results were NOT statistically significant (p > .05), do NOT calculate the effect size. Instead, skip to the reporting section below.

EFFECT SIZE CODE

PURPOSE

Determine how strong the similarity was between what was observed versus what was expected.

 W <- sqrt(chisq_gfit$statistic / sum(observed))
 W
## X-squared 
## 0.3139217

DETERMINE THE SIZE OF THE EFFECT

0.00 to 0.09 = ignore 0.10 to 0.29 = small 0.30 to 0.49 = moderate 0.50+ = large

Result Report

A Chi-Square Goodness-of-Fit Test was conducted to determine whether dessert preference (Tiramisu, Cheesecake, ChocoCake) was different from an equal distribution (33.33%, 33.33%, 33.33%) among 548 participants. There was a statistically significant difference in car type preferences, χ²(2, N = 548) = 54.004, p = 1.876e-12. Participants preferred “Chococake” more than Tiramisu or Cheesecake. The effect size was medium (Cohen’s W = 0.3139217).