I have a question on categorical data –
I have a 2×4 matrix and I want to test the difference in the number of males or females in each group, and so I entered the data into R.
So I input this:
A=c(31,7)
B=c(8,1)
C=c(39,16)
D=c(2,6)
tab=as.table(cbind(A,B,C,D))
row.names(tab)=c('males','females')
fisher.test(tab)
This is the output that I get –
Fisher's Exact Test for Count Data
data: tab
p-value = 0.01077
alternative hypothesis: two.sided
The only statistical information I get is the p-value – how do I know how the groups are different?
Best Answer
In a sense this is analogous to a situation where you test for differences in group means with ANOVA and then perform a post hoc test, such as Tukey's HSD, to tell which groups are the ones that actually differ. But, there is no equivalent post hoc test for Fisher's test.
The only "post hoc" thing that comes to mind is to run all pairwise comparisons for the table, and correct the p-values accordingly with, e.g., the Bonferroni method.
For a Chi square test, you could check the residuals or simply the expected-observed counts. In addition, going throught the percentages of observations in each group would probably answer your question at least partly, and this could be used with either Fisher's or Chi square test.
In R these can be done as follows: