#Chi-Square Test of Independence Report

Introduction

The purpose of this analysis was to determine whether there is an association between student type (Domestic vs. International) and pet ownership (Yes vs. No). Because both variables are categorical, a Chi-Square Test of Independence was the appropriate statistical test.

A Chi-Square Test of Independence evaluates whether two categorical variables are related or associated with one another. This test does not require assumptions of normality, as categorical data cannot be normally distributed.

Open the Installed Packages

library(readxl) 
library(ggplot2) 
library(rcompanion)

Import and Name Dataset

DatasetB2 <- read_excel("C:/Users/susmi/Downloads/DatasetB2.xlsx")

Data Description

The dataset (DatasetB2) consisted of responses from 100 students. The variable PetOwnership indicated whether a student owned a pet (Yes or No), and the variable StudentType categorized students as Domestic or International.

Create a Frequency Table

tab <- table(DatasetB2$StudentType, DatasetB2$PetOwnership)

Frequency tables showed that pet ownership was evenly split, with 50 students reporting owning a pet and 50 reporting not owning a pet. Student type was also relatively balanced, with 52 Domestic students and 48 International students.

Create a Bar Chart

ggplot(DatasetB2, aes(x = StudentType, fill = PetOwnership)) +
  geom_bar(position = "dodge") +                 
  labs(
    x = "StudentType",
    y = "Frequency",
    title = "PetOwnership by Students"
  ) +
  theme(
    text = element_text(size = 14),
    axis.title = element_text(size = 14),
    axis.text = element_text(size = 14),
    plot.title = element_text(size = 14),
    legend.position = "none"                 
  )

A bar chart was generated to visually compare pet ownership between Domestic and International students. The bar chart showed similar patterns of pet ownership across both student groups, suggesting little to no difference between them.

Conducting the Chi-Square Test of Independence

chisq.test(tab)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  tab
## X-squared = 0.040064, df = 1, p-value = 0.8414

The Chi-Square Test of Independence indicated there was/ was not a significant association between StudentType and PetOwnership, χ²(1) = 7.84, p = .009. The association between the two variables was moderate (Cramer’s V = 0.4).

cramerV(tab)
## Cramer V 
##  0.04003