1

I have a list of endoscopic findings from my study and want to check if there is any statistical difference between the counts between two groups of patients. The number of patients in groups A and B are 143 and 127 respectively. For example, the count for gastritis is 17 each. How do I go about calculating the p-value? Do I have to do a 2 by 2 table?

I have seen in other medical research where a p-value is present when comparing counts between two groups

utobi
  • 11,726
Zain
  • 11
  • 1
    Hello and Welcome to CV! You may use a test for the difference between two independent proportions. – utobi Jan 09 '24 at 09:04

2 Answers2

1

You can perform this using a test for the difference between two proportions of two independent samples. This test is implemented in R through the function prop.test.

In your case, it can be used like this

> prop.test(x = c(17,17), n = c(143,127))
2-sample test for equality of proportions with continuity correction

data: c(17, 17) out of c(143, 127) X-squared = 0.034776, df = 1, p-value = 0.8521 alternative hypothesis: two.sided 95 percent confidence interval: -0.10191424 0.07195994 sample estimates: prop 1 prop 2 0.1188811 0.1338583

utobi
  • 11,726
  • Thank you for your answer. I refer to table 2 of this paper as an example. https://www.jrd.or.kr/journal/view.html?volume=26&number=1&spage=66. I used the formula to calculate the p value as in Table 2 however I can't seem to reproduce this. – Zain Jan 09 '24 at 10:14
  • 1
    Note that: 1. the numbers were 17 and 17 rather than 12 and 12. 2. the statistic and p-value are just as would be obtained by making a 2x2 table of gastritis and not-gastritis numbers and passing that matrix to chisq.test. (This is not in any sense a critique of the choice to use prop.test, just pointing out that it's doing the same actual test here.) – Glen_b Jan 09 '24 at 10:35
  • @Glen_b thank your for both comments. 1. corrected. For 2. I can't see how to build a 2x2 table given that you only have one classification variable. Am I missing something? – utobi Jan 09 '24 at 11:20
  • @Zain, in Table 2 see my updated answer, now using the numbers in your post. To which "gastritis" are you referring to in Table 2 ? – utobi Jan 09 '24 at 11:22
  • 1
    The two margins are group (A/B) and gastritis status (have it vs don't have it). The numbers in the table are 17,17 and 143-17,127-17 e.g. try chisq.test(matrix(c(17,17,143-17,127-17),nr=2)). Same answer is given by prop.test(c(17,17), c(143,127)) – Glen_b Jan 09 '24 at 14:51
1

There are three options that I can see: 1) A chi-square test on the 2x2 table. 2) A test of proportions 3) A count regression analysis. For a comparison of the first two, see this thread, for a comparison of Poisson regression (and, implicitly, other count models) to chi square see this thread.

Peter Flom
  • 119,535
  • 36
  • 175
  • 383