# Chi squared test on group counts from different sizes

I want to check screening count has changed over a time period within RACE. I have the results for two time periods. 1st is for 2010-2013 data and another for 2014-2019 data where scrn_count=screening count and eligible=Total eligible count

race_time1
RACE      scrn_count  eligble scrn_rate
<chr>       <int>       <int>    <dbl>
1 Black        3252       20589    0.171
2 Other         414        3002    0.138
3 White       28780      185109    0.155

race_time2
RACE     scrn_count   eligble scrn_rate
<chr>       <int>       <int>    <dbl>
1 Black       15180       64648    0.235
2 Other        4109       20007    0.205
3 White      117225      553467    0.212


Is it possible to do a chi sq test here? how? Should it be done only on the scrn_counts comparing two time periods? or should the eligibility counts be considered too? I was trying in R

chisq.test(cbind(race_time1$scrn_count,race_time2$scrn_count))


This gave significant result ( p value <0.001)

chisq.test(cbind(race_time1$scrn_rate,race_time2$scrn_rate))


This gave insignificant result ( pvalue =0.99)

First of all, I am not a statistics expert. My understanding is that there are different questions behind your two chi-square tests. The first tests whether the (absolute) distribution of frequencies has changed, and the second tests whether the rate has changed (sorry if I am repeating obvious things).

If you want to answer the question of whether the distribution of absolute frequencies is statistically different at the two time points, I think your first chi-square test would be appropriate for that.

However, the second question, strictly speaking, does not seem to be answerable via a chi-square test, as I understand this answer: https://stats.stackexchange.com/a/243096/347996. Perhaps this is still debatable, though.

To test whether the overall rate differs between the two time points, you could possibly use a Wilcoxon test, but as I understand this answer: https://stats.stackexchange.com/a/203214/347996, the $$p$$-value could not get smaller than $$0.1$$ in this case due to the small sample sizes ($$n = 3$$).

Another approach that takes the rates into account might be to calculate expected frequencies from the rates at the other time point and use them in a chi-square test, e.g.:

chisq.test(cbind(
race_time2$scrn_count, round(race_time2$eligble * race_time1\$scrn_rate)
))