Research Scenario B

The research web page can be found here https://rpubs.com/ivanKomak/1397910.

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

# Step 3: Import Dataset
DataSetB2 <- read_excel("/Users/komakechivan/Downloads/DatasetB2.xlsx")
Create a Contingency Table
tab_B2 <- table(DataSetB2$StudentType, DataSetB2$PetOwnership)
print(tab_B2)
##                
##                 No Yes
##   Domestic      27  25
##   International 23  25
Create a bar chart
ggplot(DataSetB2, aes(x = StudentType, fill = PetOwnership)) +
  geom_bar(position = "dodge") +
  labs(
    x = "Student Type",
    y = "Pet Ownership Status",
    title = "Pet Ownership by Student Type"
  ) +
  theme(
    text = element_text(size = 14),
    axis.title = element_text(size = 14),
    axis.text = element_text(size = 14),
    plot.title = element_text(size = 14)
  )

Conduct the Chi-Square Test of Independence
chisq_results_B2 <- chisq.test(tab_B2)
chisq_results_B2
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  tab_B2
## X-squared = 0.040064, df = 1, p-value = 0.8414

Cramer’s V (Effect Size)

cramerV(tab_B2)
## Cramer V 
##  0.04003

Interpretaion

The Chi-Square Test of Independence indicated there was NOT a significant association between student type and pet ownership, χ²(1) = 0.04, p = .841. The association between the two variables was weak (Cramer’s V = .04).