Statistically Comparing the Similarity Between Lists (e.g Food Preferences) I have the following question: Are there any statistical methods (e.g. hypothesis tests) that allow you to compare the order of two different lists?
Suppose there are two students : John and Sarah. These two students make a list of the foods they ate in the last week and how often they ate them:
           food frequency name
    ice cream        15 john
 french fries        13 john
         cake        12 john
       oranges        11 john
     pineapple        11 john
         pizza        11 john
         sushi        11 john
       apples        10 john
        celery        10 john
         mango        10 john
         tacos        10 john
        grapes         8 john

           food frequency  name
         sushi        14 sarah
         cake        14 sarah
         pizza        12 sarah
         tacos        12 sarah
        grapes        11 sarah
     pineapple        11 sarah
 french fries        11 sarah
       apples        10 sarah
       oranges        10 sarah
        celery        10 sarah
         mango        10 sarah
    ice cream        10 sarah

Question: Do any statistical methods exist that allow you to determine how similar are the food preferences between both of these students?
For example - looking at this list, I can see that both students ate a lot of cake in the last week (3rd most popular choice for John and 2nd most popular choice of Sarah), and both students did not eat a lot of mango (3rd least popular choice for John and 2nd least popular choice for Sarah).
But apart from these manual comparisons, are there any statistical methods which allow you to compare the similarity between the food preferences between both students? For instance, could some statistical method conclude that the overall preferences of both students are "approximately the same"?
I came across a few methods such as the Wilcox Rank Test (https://en.wikipedia.org/wiki/Wilcoxon_signed-rank_test), but I am not sure if this statistical test can be directly applied to this type of question.
Does anyone have any ideas?
Thanks!
 A: Rearranging the data so the foods are in the same order (John's),
I got the following vectors, each of 12-counts (you should proofread them):
jo = c(15, 13, 12, 11, 11, 11, 11, 10, 10, 10, 10, 8)
sa = c(15, 13, 12, 11, 11, 11, 11, 10, 10, 10, 12, 11)

Then I plotted the vectors against each other. [First as is, where some
points overplot.  Then (right panel) with slight jittering (random displacements), so that all 12 foods show as separate points.]
par(mfrow=c(1, 2))
  plot(jo, sa, pch=20)
 Jo = jo + runif(12, -.2, .2) # jittered
 Sa = sa + runif(12, -.2, .2) #
  plot(Jo, Sa)
par(mfrow=c(1, 2))


The plots show a clear positive association (that is, the two students tend to share food preferences).
Spearman's correlation is Pearson correlation of data ranks.
cor(jo, sa, method="spearman")
[1] 0.7078117    # Spearman
cor(rank(jo), rank(sa))
[1] 0.7078117    # Pearson for ranks

A cor.test in R whether the Spearman correlation is significantly different from $0$
does not give an exact P-value because of the ties, but does seem to reject
the null hypothesis of $0$ association. (The corresponding test for
Pearson correlation assumes that data are normal, which yours are not.)
cor.test(jo, sa, meth="spear")

        Spearman's rank correlation rho

data:  jo and sa
S = 83.566, p-value = 0.01001
alternative hypothesis: true rho is not equal to 0
sample estimates:
      rho 
0.7078117 

Warning message:
In cor.test.default(jo, sa, meth = "spear") :
  Cannot compute exact p-value with ties

Jittering breaks the ties, but loses some information. Even so, a Spearman
correlation test on jittered data is still significant at the 5% level. [Moreover, tests on most alternative randomly jittered data also give significant results.]
cor.test(Jo, Sa, meth="s")$p.val
[1] 0.0457531

For more details on the theory and programming of Spearman correlation tests in the presence of ties, see
This Q&A.
Notes: (1) I see no reason to do a Wilcoxon test on the paired data. If significant
(which it's not), that would show that one student tended to eat more (consistently higher counts) than the other.
wilcox.test(jo, sa, pair=T)$p.val
[1] 0.3710934
Warning message:
In wilcox.test.default(jo, sa, pair = T) :
  cannot compute exact p-value with zeroes

(2) You could use a chi-squared test, but it would be significant if preferences
were markedly different. A chi-squared test for homogeneity of counts returns
P-value $1.$ The small chi-squared statistic does indicate good agreement
between the two students, but correlations are a more direct way to see that.
chisq.test(rbind(jo, sa))

        Pearson's Chi-squared test

data:  rbind(jo, sa)
X-squared = 0.56276, df = 11, p-value = 1

