# The effect of sample size on chi-square test

I have two categorical variables and I want to do the chi-squared test. I was wondering if the gap between the sample sizes in each cell will affect the results?

         normal    nonormal
test1   n=6000      n=6000
test2   n=2500      n=2500


Yes. As the number of observations increases, the power of the test increases. Intuitively, as we have more data, we can be more certain about our effect size not being attributable to noise.

In terms of the actual test, the null distribution (the chi-squared distribution with # of cells - 1 degrees of freedom) remains fixed across any sample size, but the chi-squared test statistic will grow with the sample size.

Consider the following example from the wikipedia page, where the effect size (proportions between cells) remains fixed, but the sample size grows:

worker_data <- as.matrix(data.frame(white_collar = c(90,60,104,95,349),
blue_collar = c(30,50,51,20,151),
no_collar = c(30,40,45,35,150)))

chisq.test(worker_data)

Pearson's Chi-squared test

data:  worker_data
X-squared = 24.571, df = 8, p-value = 0.001837

chisq.test(worker_data * 2)

Pearson's Chi-squared test

data:  worker_data * 2
X-squared = 49.142, df = 8, p-value = 5.97e-08