# Relation between two ordinal variables

For a university course, a friend of mine had to test whether there is a relation between two ordinal variables. These variables were opinion about the European Union (positive, neutral, negative) and whether people felt being (a) citizen of their country, (b) primarily citizen of their country, but also European, (c) primarily European, but also citizen of their country and (d) European. The data is available in form of a contingency table.

Now, what my friend did was to calculate a chi-squared test. I believe this is wrong, because it does not consider the fact that the groups are ordered, i.e. the variables are ordinal and not categorial. However, chi-squared test seems to be common for this kind of analysis (e.g. here).

In my opinion, the idea behind this question is whether or not there is a significant correlation between those variables, and since Pearson’s correlation cannot be calculated from ordinal data, Spearman’s Rho should be used. An alternative to that would be Goodman’s/Kruskal’s Gamma test, as suggested here. Perhaps the Kruskal Wallis test would also be an option? But can it be used in this setting?

So, my first question is: Is it valid to use the chi-squared test here? What do you think of the alternatives I described?

Question two: How can the significance of Spearman’s correlation be calculated in R? It seems to me most commands reqire observations, not contingency tables, as input.

• Spearman's $\rho$ as well as Kruskal-Wallis are for ordinal continuous variables, whereas your variables or ordered categorical ones. It seems like you could have a look at the linear-by-linear test suggested by Agresti (Introduction to Categorical Data Analysis, 2007, p229 ff). It is implemented in R in function lbl_test() from package coin. – caracal May 9 '12 at 12:45
• What is the difference between ordinal continuous and ordered categorical variables? After all, I could always code the categories with values ranging from 1–4 or 1–3. (And this is what I suppose R is doing when it calculates Spearman’s ρ in my data.) – mzuba May 9 '12 at 16:34
• Assigning numerical scores to categories is what's happening in the LBL-Test, but then the variable still can take on only finitely many values. Continuous vars can take on uncountably infinitely many values. Spearman's $\rho$ is Pearson's correlation for ranks. To derive the distribution of the test statistic, you need unique ranks, i.e., zero probability of ties (equal values, hence ranks). For this you need continuity. With only a few categories, many ties are guaranteed, there are different ways to assign ranks (mid-ranks, ...), and the distribution of the test statistic is not available. – caracal May 10 '12 at 8:36