Chi-Square Test of Independence

This analysis is for Research Scenario 2 from Assignment 4. It tests to see if there is a “relationship between uniform design and parent”.

Hypotheses

  • H0 (Null Hypothesis): There is no association between uniform design and parent.
  • H1 (Alternate Hypothesis): There is an association between uniform design and parent.

Rusults Paragraph

  • A Chi-Square Test of Independence was conducted to examine the association between parent (Mother, Father) and uniform design preference (Design A, Design B) among 100 participants. There was NOT a statistically significant association between parent and uniform design preference, χ²(1, N = 100) = 3.2452, p = .07(> .05).

R Code and Analysis

# INSTALL REQUIRED PACKAGE

# install.packages("readxl")

# LOAD THE PACKAGE

library(readxl)

# IMPORT THE EXCEL FILE INTO R STUDIO

dataset <- read_excel("/Users/guminhe/Downloads/RQ2.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 TABLE 

contingencytable <- table(dataset$Parent, dataset$Preferred_Design)
print(contingencytable)
##         
##           A  B
##   Father 21 29
##   Mother 31 19
# ====================================
# CHI-SQUARE TEST OF INDEPENDENCE CODE
# ====================================

# PURPOSE
# Determine if the null or alternate hypothesis was supported.

# CONDUCT THE TEST

chisq_indep <- chisq.test(contingencytable)
print(chisq_indep)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  contingencytable
## X-squared = 3.2452, df = 1, p-value = 0.07163
# DETERMINE STATISTICAL SIGNIFICANCE

# ================
# EFFECT SIZE CODE (No need for this)
# ================

# PURPOSE
# Determine how strong the relationship was between the two variables.

# INSTALL REQUIRED PACKAGE

# install.packages("lsr")

# LOAD THE PACKAGE

library(lsr)

# CALCULATE CRAMER'S V

cramers_v <- cramersV(contingencytable)
cat("Cramer's V (effect size):", round(cramers_v, 3), "\n")
## Cramer's V (effect size): 0.18