library(readxl)
library(rcompanion)
library(ggplot2)
Data <- read_excel("C:/Users/SHRUTI/Downloads/A4Q2.xlsx")
Data
## # A tibble: 300 × 3
## ID status scholarship
## <dbl> <chr> <dbl>
## 1 1 Domestic 1
## 2 2 Domestic 0
## 3 3 Domestic 1
## 4 4 Domestic 0
## 5 5 Domestic 0
## 6 6 Domestic 1
## 7 7 Domestic 1
## 8 8 Domestic 0
## 9 9 Domestic 1
## 10 10 Domestic 1
## # ℹ 290 more rows
# Create frequency table with TWO variables
contingency_table <- table(Data$status, Data$scholarship)
contingency_table
##
## 0 1
## Domestic 39 111
## International 118 32
barplot(contingency_table,
beside = TRUE,
col = rainbow(nrow(contingency_table)),
legend = rownames(contingency_table),
main = "Scholarship Status by Student Status",
xlab = "Scholarship",
ylab = "Count")

# Conduct Chi-Square Test of Independence
chi_result <- chisq.test(contingency_table)
chi_result
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: contingency_table
## X-squared = 81.297, df = 1, p-value < 2.2e-16
# Calculate Cramer's V
cramers_v <- rcompanion::cramerV(contingency_table)
cramers_v
## Cramer V
## 0.5272
# A Chi-Square Test of Independence was conducted to determine if there was an association between student status (Domestic or International) and scholarship status (Yes or No).
# The results showed that there was an association between the two variables, χ²(1) = 81.30, p < .001.
# The association was large (Cramer's V = .53).