# Is a Fisher exact test for count data appropriate with an ordered factor?

I have the following contingency table:

tab = structure(c(35L, 28L, 5L, 11L, 16L, 3L, 8L, 16L, 2L, 5L, 10L,
10L), .Dim = 3:4, .Dimnames = structure(list(question = c("Faculty",
"Graduate student", "Research staff"), value = c("Never", "Rarely",
"Occasionally", "Frequently")), .Names = c("question", "value"
)), class = "table")


Which looks like this:

              value
question           Never Rarely Occasionally Frequently
Faculty             35     11            8          5
Graduate student    28     16           16         10
Research staff       5      3            2         10


I plan to use a Fisher exact test because a Chi-square test results in expected values < 5:

chisq.test(tab)\$expected

value
question               Never    Rarely Occasionally Frequently
Faculty          26.926174 11.879195    10.295302   9.899329
Graduate student 31.946309 14.093960    12.214765  11.744966
Research staff    9.127517  4.026846     3.489933   3.355705


I'm concerned however, because my columns are an ordered factor. Never through Frequently is a spectrum rather than a normal categorical variable.

Is the Fisher exact test or chi-square test appropriate for such a contingency table? Does it matter that my factor is ordered? Is there another test that uses this ordered characteristic better?

• Cannot answer the first part but for comparing ordinal variable across >2 groups, you may consider Kruskal Wallis test. May 17, 2016 at 18:33

The chi-square test is appropriate to use with ordinal data but, as you have found, some of your expected frequencies are <5. If your groups are independent and n <30 you can use the Wilcoxon rank-sum test. If the groups are not independent, not normally distributed and n < 30, you can use the Wilcoxon signed ranks test. One tests that the means are equal and the other tests that the medians are equal. Both are appropriate for ordinal data. This is from Basic and Clinical Biostatistics, 4th edition, by Dawson and Trapp, 1994.

• There are 3 groups. Are you recommending 3 rank-sum tests? May 17, 2016 at 19:53
• Is there benefit to using a Wilcoxon rank-sum or signed ranks test over the chi-square or Fisher test? May 18, 2016 at 16:03

Well, if you check the help of Fisher's exact test in R:

?fisher.test


in the end, there's an example where both variables are ordinal. The table is as follows:

## A r x c table  Agresti (2002, p. 57) Job Satisfaction
Job <- matrix(c(1,2,1,0, 3,3,6,1, 10,10,14,9, 6,7,12,11), 4, 4,
dimnames = list(income = c("< 15k", "15-25k", "25-40k", "> 40k"),
satisfaction = c("VeryD", "LittleD", "ModerateS", "VeryS"))

Job
satisfaction
income   VeryD LittleD ModerateS VeryS
< 15k      1       3        10     6
15-25k     2       3        10     7
25-40k     1       6        14    12
> 40k      0       1         9    11

fisher.test(Job)
Fisher's Exact Test for Count Data

data:  Job
p-value = 0.7827
alternative hypothesis: two.sided



As you can see, this example is from Agresti's book Categorical Data Analysis (2002). I checked the book but seems he didn't mention Fisher's exact test in this part.

As R's help is using this example to run a Fisher's test I assume it's valid to run Fisher's test for ordinal variables too, but would be good to confirm it!

The assumption behind Fisher's exact test is that both variables (membership and frequency) are multinomially distributed, i. e. there are set percentages of a given person being a faculty member, a graduate student, or research staff; and set percentages for a given person being "never", "rare", etc.

On a technical level, this assumption is not used because the row and column sums are assumed to be fixed in the actual calculation but the above is what this simplification is supposed to approximate.

Coming back to your question, the fact that the second variable (frequency) is ordered has no impact on the original assumption so solely based on this consideration you can go ahead and use Fischer's exact test.

However, since your data seems to come from field observation where neither the number of people in each group nor the number in each frequency group is controlled by you you might consider using Boschloo's exact test with a multinomial model wich is more powerful than Fischer's test and more fitting for your use case.