I have data from an experiment that consist of nominal-scale responses that subjects made in two treatments (the treatments are between subjects, not repeated measures). I've provided my data in data frame and table form below. My goal is to compare the distributions of the responses in the two treatments - t1
and t2
- to see if they are significantly different from one another. I am not interested in differences among levels of the response variable (e.g., between response a
and c
).
I'm unsure how to approach this. My first thought was a Fisher exact test of the 8x2 contingency table (tab
below), which yields: p-value = 0.2102
. However, it seems that this tests whether the response variable is associated with the treatment variable as a whole, rather than testing for a difference between the treatments. Any suggestions for a better approach are most welcome.
# data frame with treatments and responses
df <- structure(list(id = 1:30, treatment = structure(c(2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L), .Label = c("t1",
"t2"), class = "factor"), response = structure(c(2L, 1L, 1L,
1L, 1L, 1L, 6L, 8L, 1L, 1L, 4L, 1L, 1L, 1L, 5L, 1L, 7L, 1L, 8L,
1L, 4L, 1L, 4L, 2L, 1L, 1L, 1L, 3L, 1L, 1L), .Label = c("a",
"b", "c", "d", "e", "f", "g", "h"), class = "factor")), .Names = c("id",
"treatment", "response"), row.names = c(1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L), class = "data.frame")
# 8x2 contingency table
tab <- structure(c(12L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 7L, 1L, 0L, 3L,
1L, 1L, 1L, 1L), .Dim = c(8L, 2L), .Dimnames = structure(list(
response = c("a", "b", "c", "d", "e", "f", "g", "h"), treatment = c("t1",
"t2")), .Names = c("response", "treatment")), class = "table")