# 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

• Is it possible to compare P values coming from different chi-squared test of homogeneity, each of these with different sample sizes? Since the sample size affects significance, it sounds that comparison will not be independent of sample sizes. Feb 7, 2020 at 17:02
• @elcortegano I'm not sure what you mean by "compare" and in what setting you want to do this. As usual, a p-value from this test represents the probability of measuring an effect size as strong as observed, given no "true" effect exists. p-values can be treated just like any conditional probabilities; that the test statistic is dependent on sample size (at fixed effect size) does not change this.
– khol
Feb 8, 2020 at 4:17