Maybe you have data something like my fake data for 200 'subjects' graphed below, where x
has 200 scores
between 1 and 5, and y
shows Option chosen. [Simulation and graph from R.]
stripchart(x ~ y, pch="|", ylim=c(.6,3.4))
If you're just interested in correlation, I'd suggest Spearman
correlation between numerical scores x
and ordinal categorical options y
.
Spearman correlation is based on ranks, and ordinal options can be ranked.
cor(x,y, method="s")
[1] 0.62997
A Kruskal-Wallis test shows highly significant differences in scores for the three options.
kruskal.test(x ~ y)
Kruskal-Wallis rank sum test
data: x by y
Kruskal-Wallis chi-squared = 79.208, df = 2, p-value < 2.2e-16
Ad hoc 2-sample Wilcoxon rank sum tests show significant differences
in scores between Options 1 & 2 and between Options 2 & 3.
wilcox.test(x[y==1],x[y==2])$p.val
[1] 4.815738e-08
wilcox.test(x[y==2],x[y==3])$p.val
[1] 4.225357e-10
Depending on your objectives, you should also consider ordinal regressions as suggested by @kjetilbhalvorsen.
Note: In case you want to the individual values for x
and y
here
is the code I used to simulate them:
set.seed(2020)
x1 = round(4*rbeta(50, 1,3)+1, 2)
x2 = round(4*rbeta(100,2,2)+1 ,2)
x3 = round(4*rbeta(50, 3,1)+1, 2)
x = c(x1,x2,x3)
y = rep(1:3, c(50,100,50))
Addendum, Changing data to integers: Based on discussion in Comments.
set.seed(2020)
x1 = round(4*rbeta(50, 1,3)+1)
x2 = round(4*rbeta(100,2,2)+1)
x3 = round(4*rbeta(50, 3,1)+1)
x = c(x1,x2,x3)
y = rep(1:3, c(50,100,50))
cor(x,y, method="s")
[1] 0.6035967
kruskal.test(x~y)
Kruskal-Wallis rank sum test
data: x by y
Kruskal-Wallis chi-squared = 73.012, df = 2,
p-value < 2.2e-16
TAB = rbind(c(tabulate(x1),0),tabulate(x2),tabulate(x3))
TAB
[,1] [,2] [,3] [,4] [,5]
[1,] 14 24 9 3 0
[2,] 8 26 39 23 4
[3,] 1 3 8 17 21
Chi-squared test rejects null hypothesis that
HH and Choice (both treated as nominal, not ordinal, variables) are independent. Unlike
Spearman correlation the chi-squared says
nothing about the direction of the association.
chisq.test(TAB)
Pearson's Chi-squared test
data: TAB
X-squared = 98.331, df = 8, p-value < 2.2e-16
Table may be the best data display, but here is a marginally satisfactory version of a stripchart, using jitter
(small random displacements) to
minimize overplotting).
stripchart(x~y, method="jitter", pch="-")
After rounding HH scores to integers, everything
works fine for my fake data. Choose the tests
that you believe best match your data and
objectives. (Inappropriate to try everything and just report what happens to show significance.)