0

I have a 3x3 contingency table and would like to compare the the specific proportion's relationship.

3x3 contingency table

For example, can we test if the proportion of people who give response A in age group 1 is higher than that in age group 3?

João Bravo
  • 109
  • 8
Simone
  • 1
  • 1
    Welcome to CV, Simone! Can you clarify whether you are interested in a *post hoc* pairwise test (i.e. *after* you have rejected the null hypothesis from an omnibus contingency table test across three age groups and three response categories), or just whether you can conduct a simple test of proportion difference? – Alexis Oct 12 '20 at 16:33
  • 3
    Of possible interest: [How to analyze 2× contingency table?](https://stats.stackexchange.com/q/173725/930), and other QAs on post-hoc comparisons on contingency tables on this site. – chl Oct 12 '20 at 19:44
  • Since @chl mentioned it, I asked about [Pooled variance for *post hoc* tests for contingency table $\chi^{2}$ tests](https://stats.stackexchange.com/questions/331092/pooled-variance-for-post-hoc-tests-for-contingency-table-chi2-tests) – Alexis Oct 13 '20 at 01:00

1 Answers1

0

The null hypothesis of independence is strongly rejected by a chi-squared test:

a = c(13,25,28); b = c(21,31,24); c = c(21,20,4)
TBL = rbind(a,b,c);  TBL
  [,1] [,2] [,3]
a   13   25   28
b   21   31   24
c   21   20    4
colSums(TBL)
[1] 55 76 56
chisq.test(TBL)

        Pearson's Chi-squared test

data:  TBL
X-squared = 17.202, df = 4, p-value = 0.001766

An ad hoc prop.test in R, of the null hypothesis that the proportion of As in Age groups 1 and 3 is the same is also strongly rejected, as shown below. However, the proportion in Gp 1 is smaller than the proportion in Gp 3.

prop.test(c(13,28), c(55, 56))

        2-sample test for equality of proportions 
        with continuity correction

data:  c(13, 28) out of c(55, 56)
X-squared = 7.1863, df = 1, p-value = 0.007346
alternative hypothesis: two.sided
95 percent confidence interval:
 -0.45415527 -0.07311746
sample estimates:
   prop 1    prop 2 
0.2363636 0.5000000 

Note: Even if this second test is your main goal, it would be not be appropriate to do that test until first testing whether the overall table is consistent with independence of Age and Response. Suppose Age and Response are independent, but you notice a discrepancy in counts, which you test and find significant. That could be just by chance, and you will have made a 'false discovery'.

For a simpler example: Suppose you have six age categories, 30 subjects per category, with possible responses Yes and No. Actually, all six categories have the same probability $(1/6)$ of Yes answers. But Yes counts happen to be $4, 3, 9, 4, 6, 2.$ You notice that $9$ and $2$ are quite different, and prop.test does find a significant difference. That means nothing. You have hand-picked the extremes. Doing this, you will often find bogus "differences."

set.seed(1212)
rbinom(6,30,1/6)  # All six categories actually same
[1] 4 3 9 4 6 2   # Happen to get min 2 and max 9
prop.test(c(9,2),c(30,30))  # Bogus test of extremes

        2-sample test for equality of proportions 
        with continuity correction

data:  c(9, 2) out of c(30, 30)
X-squared = 4.0074, df = 1, p-value = 0.0453  # FALSE DISCOVERY
alternative hypothesis: two.sided
95 percent confidence interval:
 0.01329788 0.45336879
sample estimates:
    prop 1     prop 2 
0.30000000 0.06666667 

In this scenario, if Yes and No are equally likely responses for all age groups, then the false discovery rate for testing min against max is about 23%.

set.seed(2020)
pv= replicate(100000, 
     prop.test(range(rbinom(6,30,1/2)),c(30,30))$p.val)
mean(pv < 0.05)
[1] 0.23352
kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
BruceET
  • 47,896
  • 2
  • 28
  • 76
  • I suspect the Simone may be interested if there is a way to conduct *post hoc* pairwise contingency table tests following rejection of an omnibus (i.e. $\text{df}>1$) contingency table test; that is one that uses some kind of equivalent to the pooled variance estimates used in, e.g., *post hoc* unpaired *t* tests following rejection of ANOVA, *post hoc* paired *t* test following rejection of repeated measures ANOVA, Dunn's (*post hoc*) test following rejection of a Kruskal-Wallis, etc. *Post hoc* tests arn't simply independent of the omnibus. (But maybe Simone is not interested in *post hoc*?) – Alexis Oct 12 '20 at 16:29
  • I have requested that Simone clarify. – Alexis Oct 12 '20 at 16:37
  • There is no requirement, generally, to do a pairwise comparison as a post-hoc following the omnibus test. To compare two groups out of the three no chi-square test is necessary. One has the right to assume or pretend that the population consists only of the two groups being compared. – ttnphns Oct 12 '20 at 23:17
  • @ttnphns Not sure I am following your logic… textbooks generally agree that omnibus *alternate* hypotheses take the form 'at least one group differs from at least one group', but do *not* express 'any group is different from any other group'. Having rejected an omnibus null, one may naturally desire to identify *which* groups differ significantly, and one gets more power to make this differentiation by using pooled variances. Again: textbook. Not sure I am following you? – Alexis Oct 13 '20 at 01:04
  • @Alexis, variance of a binary variable is not independent of its mean, i.e. the proportion. In pairwise comparison of a proportion between groups (by means of z-test aka 2x2 chi-square test) one has not to do and usually doesn't do the preliminary omnibus test (chi-square of the full table). Just perform pairwise comparisons (with corrections for multiple. like Bonferroni, if needed). Comparing means is a bit different story and indeed often is done as post hoc after ANOVA (i.e. based on pooled variance). – ttnphns Oct 13 '20 at 01:21
  • (cont.) But even with means - people sometimes do t tests directly without ANOVA: they use variances only from the two groups being currently compared. This is less usual, but it is not illegal. – ttnphns Oct 13 '20 at 01:21
  • @ttnphns But the reliability of the mean proportion is a function of sample size, which *must* be larger when taking all groups together, instead of in pairs. *If* $\text{H}_{0}$ for the omnibus test is true, then the best estimate of the proportion is the grand sample proportion $\hat{p}$ rather than any single $\hat{p}_i$ where $i \in 1, \dots k$ for $k$ groups. (As for any combination of proportion estimates less than all $k$ of them.) **So pooled estimates of the SE apply for proportion tests.** 'Illegal' is irrelevant, pooled SEs imply *post hoc* & omnibus $\text{H}_0$s are related. – Alexis Oct 13 '20 at 02:29
  • Thank you all~~ Refer to the 2 sample test, the prop.test can only test two proportion is same, how can I test is p_1 < p_3? Thank you~~ – Simone Oct 13 '20 at 02:48
  • What I would like to know if we can just ignore Age Group 2 and compare the Age Group 1 and Age Group 3 in the 3x3 contingency table. – Simone Oct 13 '20 at 02:50
  • @Alexis, Once again: you are not obliged to do an omnibus testing (even in comparing means). You might not be interested in the H0 "All three groups come from the same population". Instead, you might take interest in testing multiple H0's: Gr1=Gr2, Gr1=Gr3, for instance, or selected H0's: Gr1=Gr2, with Gr3 reserved. – ttnphns Oct 13 '20 at 04:09
  • And note further that while with means the omnibus H0 is "all groups have the same mean _and_ the same variance", with proportions (binary data) having the same mean automatically implies the same variance. Consequently, posthoc z-tests for props. differ from apriori z-tests in no mathematical respect. The only difference being the stance towards H0 that you take, what my previous comment was about. – ttnphns Oct 13 '20 at 04:45
  • @ttnphns You need not be obligated to do statistics at all. You might, for example paint with oils over guache on wood. That said: *all* my comments have been with respect to the omnibus and *post hoc* test scenario. You want to talk about something else, that's cool. – Alexis Oct 13 '20 at 15:03
  • @Alexis: with respect to you. We were having a discussion which could be interesting and on-topic for the _OP_ (and I kept that possibility in mind). So I dare say my comments weren' completely futile. – ttnphns Oct 13 '20 at 15:19