10
$\begingroup$

I have a data set with two categorical nominal variables (both with 5 categories). I would like to know if (and how) I am able to identify potential correlations between the categories from these two variables.

In other words whether for example the results of category $i$ in variable 1 show a strong correlation with a specific category $j$ in variable 2. Since I have two variables with 5 categories, the total correlation analysis for all the categories would come down to 25 results (at least if it works the way I hope/expect it to work).

I have tried to formulate the problem into concrete questions:

Question 1: Let's say I transfer the categorical variable into 5 different dummy variables per value (category). This same procedure I run for the second variable as well. Then I want to determine the correlation between dummy 1.i and 2.i (for example). Is it statistically correct for me to execute this procedure by means of an ordinary correlation coefficient procedure? Does the correlation coefficient resulting from this procedure provide a proper insight in a correlation among the two dummy variables?

Question 2: If the procedure described in question one is a valid procedure, is there a way to execute this analysis for all categories of 2 (or perhaps more) categorical nominal variables all at once?

The program I am using is SPSS (20).

$\endgroup$
3
  • $\begingroup$ Points made by @Michael Mayer apply to the revised question. $\endgroup$
    – Nick Cox
    Commented Nov 7, 2013 at 0:11
  • 1
    $\begingroup$ If two variables are not correlated, then you'd have 1/25 in every cell of 5x5 matrix of frequencies. Hence, $\chi^2$ statistics $\sum_{xy}\frac{(O-E)^2}{E}$, where $E=\sum_{xy}O_{xy}/25$ and $O_{xy}$ - observed frequency for any of 5 values of two variables, should be suitable. $\endgroup$
    – Aksakal
    Commented Dec 24, 2014 at 5:52
  • 4
    $\begingroup$ @Aksakal "Not correlated" is the wrong term here; the variables are nominal, so correlations are not defined. I think you mean independent, but independence doesn't imply equal frequencies either. The cell frequencies under independence depend on the marginal frequencies. $\endgroup$
    – Nick Cox
    Commented Feb 25, 2015 at 17:20

3 Answers 3

11
$\begingroup$

The "focal" association between category $i$ of one nominal variable and category $j$ of the other one is expressed by the frequency residual in the cell $ij$, as we know: $n_{ij}-E_{ij}$, where $E_{ij}$ is the expected count under no association hypothesis. If the residual is 0 then it means the frequency is what is expected when the two nominal variables are not associated. The larger the residual the greater is the global association due to the overrepresented combination $ij$ in the sample. The large negative residual equivalently says of the underrepresented combination. So, frequency residual is what you want.

Raw residuals are not suitable though, because they depend on the marginal totals and the overall total and the table size: the value is not standardized in any way. But SPSS can display you standardized residuals also called Pearson residuals. St. residual is the residual divided by an estimate of its standard deviation (equal to the sq. root of the expected value, because a count comes from Poisson distribution, where variance = expected value).

$$\mathrm{Std.res.}_{ij}=\frac{n_{ij}-E_{ij}}{\sqrt{E_{ij}}}$$

Chi-square statistic of a contingency table is the sum of the squared std. residuals in it. Comparing std. residuals in a table and across same-volumed tables helps identify the particular cells that contribute most to the chi-square statistic. Std. residuals are comparable between different tables of same size and the same total $N$.

Std. residual in a cell follows normal $\mathscr{N}(0,\le1)$ distribution. So one may declare this residual greater than 2 or 3 by absolute value as significant one, telling of over- or under-representedness in the cell. However, because of $\le1$ sampling variance, std. residual is not fully a z-score of the normal distribution, and basing the inference of significance on it is conservative.

We may further divide std. residual by an estimate of its standard error, to obtain adjusted standardized residuals (= adjusted residuals), which SPSS also displays.

$$\mathrm{Adj.res}_{ij}=\frac{\mathrm{Std.res.}_{ij}}{\sqrt{(1-n_{i.}/N)(1-n_{.j}/N)}}$$

where $n_{i.}$ and $n_{.j}$ are the marginal counts of the row and the column. Now adj. residual in a cell follows normal $\mathscr{N}(0,1)$ distribution; it is a true z-score. If adj. residual is above 1.96 or below -1.96 you may conclude it is significant at p<0.05 level$^1$. 2.58 or -2.58 - for p<0.01 conclusion.

Unlike std. residual, adj. residual appear also standardized wrt to the shape of the marginal distributions in the table (it takes into consideration the expected frequency not only in that cell but also in the cells outside its row and its column) and so you can directly see the strength of the tie between categories $i$ and $j$ - without worrying about whether their marginal totals are big or small relative the other categories' marginals.

Interesting, that adj. residual is just equal to $\sqrt{N}r_{ij}$, where $r_{ij}$ is the Pearson correlation (alias Phi correlation) between dummy variables corresponding to the categories $i$ and $j$ of the two nominal variables. This $r$ is exactly what you say you want to compute. Adj. residual is directly related to it. Adj. residuals are still effected by $N$; $r$'s are not, but you can obtain all the $r$s from adj. residuals, following the just said formula, without spending time to produce dummy variables.$^2$

In regard to your second question, about 3-way category ties - this is possible as part of the general loglinear analysis which also displays residuals. However, practical use of 3-way cell residuals is modest: 3(+)-way association measures are not easily standardized and are not easily interpretable.


$^1$ In st. normal curve $1.96 \approx 2$ is the cut-point of 2.5% tail, so 5% if you consider both tails as with 2-sided alternative hypothesis.

$^2$ It follows that the significance of the adjusted residual in cell $ij$ equals the significance of $r_{ij}$. Besides, if there is only 2 columns in the table and you are performing z-test of proportions between $\text {prop}(i,1)$ and $\text {prop}(i,2)$, column proportions for row $i$, the p-value of that test equals the significance of both (any) adj. residuals in row $i$ of the 2-column table.

$\endgroup$
0
3
$\begingroup$

I recommend just doing variable clustering of the set of variables. For example the R Hmisc package varclus function will automatically create all the needed indicator variables and perform a hierarchical cluster analysis on a similarly matrix formed from squared correlation coefficients. In this case the correlations are all computed on binary variables. You can request a special binary variable similarity measure be used instead related to Pr(A and B) - Pr(A)Pr(B). See this and this.

$\endgroup$
2
$\begingroup$

Directly taken from a document on bivariate statistics with SPSS that lives here:

Chi-square is a useful technique because you can use it to see if there’s a relationship between two ordinal variables, two nominal variables, or between an ordinal and a nominal variable. You look at the assymp. Sig column and if it is less than .05, the relationship between the two variables is statistically significant.

$\endgroup$
3
  • 4
    $\begingroup$ OK, but three grumbles, one major, two very minor. Chi-square on two ordinal variables ignores the ordering. This isn't the SPSS document, but an elementary introduction by someone else, and they over-simplify, as just mentioned. They didn't copy "Asymp." correctly (example on previous page). The bigger issue for the OP is that correlation is the wrong word here: "association" is the key-word, in terms of measuring, testing and (best of all) modelling the association. $\endgroup$
    – Nick Cox
    Commented Nov 6, 2013 at 9:15
  • 1
    $\begingroup$ Thanks, I edited the SPSS document bit, it was not my intention to attach any undue authenticity to it . $\endgroup$
    – Zhubarb
    Commented Nov 6, 2013 at 9:24
  • 1
    $\begingroup$ Link now seems dead. $\endgroup$
    – Nick Cox
    Commented Oct 22, 2022 at 1:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.