# Which test to use? looking for approval [closed]

I have a multiple categorized table. The columns are three+- categories which I want to compare (pairwise - 2 each time). For instance:

Categories       | Alpha + | Beta + | Alpha -
Total population | 630     | 45     | 127
Stage 1          | 124     | 12     | 17
Stage 2          | 45      | 19     | 28
Stage 3          | 234     | 4      | 2
Stage 4          | 64      | 5      | 10
Unknown          | 163     | 5      | 70


The N (total population) is different. How would I know that between the ratio between Alpha+ & Beta+ in Stage 2 is significantly different? I thought about T test because the data isn't a-parametric

*Edited -> Is stage 1 in alpha+ is significantly lower/higher in ratio than stage 1 beta +? taking in account that alpha + total population is 630 and in stage 1 there are 124 people out of 630 while beta+ population is 45, there are 12 people in stage 1. Same about each stage, individually.

• Chi-squared test on counts, not t test. See my Answer. May 29, 2021 at 18:48

One method is to use a chi-squared test for homogeneity. Let's compare A+ and B+. The test is a bit difficult because counts for 'Stage5' and 'Unknown' are so small for B+. The null hypothesis is that the (proportions of) 'Stages' are similarly distributed in A+ and B+.

This test requires a contingence table such as TAB below:

A = c(124, 45, 234, 64, 163)
B = c(12, 19, 4, 5, 5)
sum(A); sum(B)
 630
 45
TAB = rbind(A,B);   TAB
[,1] [,2] [,3] [,4] [,5]
A  124   45  234   64  163
B   12   19    4    5    5


Then in R, chisq.test gives the following output:

chisq.test(TAB)

Pearson's Chi-squared test

data:  TAB
X-squared = 68.75, df = 4, p-value = 4.166e-14

Warning message:
In chisq.test(TAB) :
Chi-squared approximation may be incorrect


The expected counts $$E_{ij}$$ for this test are found from row and column totals based on the null hypothesis that the 'Stage' distributions are the same for A+ and B+. If all of the $$E_{ij} > 5,$$ then the chi-squared statistic $$Q = 68.75:$$ $$Q = \sum_{i=1}^5\sum_{j=1}^2\frac{(X_{ij}-E_{ij})^2}{E_{ij}} \stackrel{aprx}{\sim}\mathsf{Chisq}(\nu = (5-1)(2-1_ = 4),$$ where $$X_{ij}$$ are entries in TAB.

For your data the $$E_{ij}$$ are shown below. Notice that the row for B has two counts barely below $$5.$$ Thus, the very small P-value, indicating that $$H_0$$ should be rejected, may not be accurate. Even so, no $$E_{ij}$$ is much less than $$5,$$ and the P-value is very far below 5%. So it one can guess that rejecting $$H_0$$ is the correct decision.

chisq.test(TAB)$exp [,1] [,2] [,3] [,4] [,5] A 126.933333 59.733333 222.13333 64.4 156.8 B 9.066667 4.266667 15.86667 4.6 11.2 Warning message: In chisq.test(TAB) : Chi-squared approximation may be incorrect  However, the implementation of chisq.test in R, permits simulating a more accurate P-value (using parameter sim=T), so guessing is not necessary. The accurate P-value is $$0.0005 < 0.01 = 1\%$$ and we may reject at the 1% level of significance. chisq.test(TAB, sim=T) Pearson's Chi-squared test with simulated p-value (based on 2000 replicates) data: TAB X-squared = 68.75, df = NA, p-value = 0.0004998  Notes: You can find a description of the chi-squared test of homogeneity in most applied statistics books. In case you are not familiar with the method of computing the $$E_{ij},$$ the R code below illustrates computation of $$E_{11} = 126.933333.$$ Other expected counts are found similarly. "Row total times column total divided by grand total." (Do not round expected counts to integers when computing $$Q.)$$ rowSums(TAB) A B 630 45 colSums(TAB)  136 64 238 69 168 sum(TAB)  675 630*136/675  126.9333  • I am using python tbh but the main idea is clear , I will try it and see how it goes, thanks May 29, 2021 at 19:00 • Could I just clarify the simulation step method (a good tool to avoid merging cells to increase low cell counts!)? What I think it does is it uses the proportions from the actuals and draws 675 times from this distribution. It then run the chi-squared test against these simulated values. It repeats this 2000 times and then takes the average p-value. Is this the method it uses? May 29, 2021 at 19:28 • Bruce, the problem is that I am trying to find the "difference" between each row individually and regardless to the other rows (which is Xij if I understood correctly?) May 29, 2021 at 19:59 • In your question you say 'ratio' and now you say 'difference', sounds imprecise at best, confusing at worst. // Are the numbers 124, 45, etc. counts? // Please say in plain English what are alpha+, beta+, and alpha-? What are 'Stages'? What do you want to know? // Please edit Question so it is self-contained and clear, May 29, 2021 at 21:21 • If applicable at all (normal dist'n would be in question), what a paired t test on two columns could tell you is that the numbers in first col are bigger than corresp, ones in 2nd; that's pretty clear without a statistical test. [if you want a test, in five times out of five, 2nd row is smaller, P-value$1/2^5 = 1/32 < 0.05 = 5\%.]\$ May 29, 2021 at 21:22