Introduction

This document walks through a Chi-Square Test of Independence to check whether there is a relationship between a student’s status (Domestic vs. International) and whether they received a scholarship (0 = No, 1 = Yes).


Step 1: Install Required Packages

You only need to run this once on your computer. After the packages are installed, you can turn this chunk off (or delete it) so it doesn’t reinstall every time.

install.packages("readxl")
install.packages("TH.Tools") - Because I couldn't download rcompanion without it!
install.packages("rcompanion")
install.packages("ggplot2")

Step 2: Load the Packages

Every time you start a new R session, you need to load the packages (even if they’re already installed).

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

Step 3: Import the Data

This reads in your Excel file. Update the file path below to match where the file is saved on your computer.

A4Q2 <- read_excel("C:/Users/CHEENA/Downloads/A4Q2.xlsx")

Step 4: Create a Frequency Table

We use table() to count how many students fall into each combination of status and scholarship.

polit_table <- table(A4Q2$status, A4Q2$scholarship)
polit_table
##                
##                   0   1
##   Domestic       39 111
##   International 118  32

Step 5: Visualize with a Bar Plot

A bar plot makes it easier to see the pattern at a glance.

barplot(polit_table, 
        beside = TRUE, 
        col = rainbow(nrow(polit_table)), 
        legend = rownames(polit_table))


Step 6: Run the Chi-Square Test

The Chi-Square Test of Independence tells us whether status and scholarship are related, or whether any difference we see is just due to chance.

chi_result <- chisq.test(polit_table)
chi_result
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  polit_table
## X-squared = 81.297, df = 1, p-value < 2.2e-16

Step 7: Effect Size (Cramer’s V)

The Chi-Square test tells us if there’s a relationship, but not how strong it is. Cramer’s V gives us that effect size.

rcompanion::cramerV(polit_table)
## Cramer V 
##   0.5272

Step 8: Write Up the Results

Using the numbers from the outputs above, here’s how you can report the results in APA style:

A Chi-Square Test of Independence was conducted to determine if there was an association between student status (Domestic vs. International) and scholarship receipt.

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).

How to fill this in yourself next time:

What to report Where to find it
df df value in the chi-square output
χ² value X-squared value in the chi-square output
p-value p-value in the chi-square output (if it’s a tiny number like 2.2e-16, just write p < .001)
Cramer’s V The number printed under Cramer V
Effect size label .10 = small, .30 = medium, .50 = large (for a 2x2 table)
“was” / “was not” “was” if p < .05, “was not” if p ≥ .05