 If you want to look at the association between two categorical or nominal variables, the most common choice is the chi-squared test of association, also called the chi-squared test of independence. And let me demonstrate how this works by starting with a split frequency. Let's come up here to exploration and descriptives, and let's look at, for instance, psych regions. This is in the state data data set that I supplied. I'm going to put that here under variables, but let's split it by whether a state has a Republican or Democrat governor. Because it's possible that there is some association between the political party of the governor and the state's personality is rated by some researchers. Now, right now, all it's telling us is that there are 48 cases in the data. I'm going to remove this extra information that I don't need. There we go. Now the table is a little bit smaller. I do want to get a frequency table. I'll click on that. And this is going to tell me how many people or really how many states that are in each combination. And then I'll also ask for a bar plot at the same time. And what we have here is that we have 20 Republican governors of states that are considered friendly and conventional. We have six Democrat governors of states that are considered temperamental and uninhibited. And we can see that in the chart down here. Again, I apologize for the overlapping labels. I'm sure that'll be fixed in the later version. The blue lines are Democrats and the yellow gold ones are Republicans. And what you see is this huge spike in terms of friendly and conventional, the vast majority of those states have Republican governors where the other ones appear to be somewhat split, a little more Republicans and the temperamental and uninhibited. But let's find out whether this difference is statistically significant, whether there is in fact a statistical association between the personality of the state and whether the governor is Democrat or Republican. So we'll use the chi-squared test of association for that. Let's come up here and go to frequencies. And then I come down here to independent samples. What that means is we have different groups of people in each of these categories or different groups of states. And it's chi-squared test of association also called the test for independence. And I'll click on that. And here's what it's going to ask me. I need to give it the rows and the columns for what's called a contingency table. That's just a table of rows and columns. So I'm going to start by putting psych region as the rows. And I'm going to put governor as the columns that will mirror the table that I already created. And I could add extra layers, but that gets really complicated and hard to interpret. What that would mean, by the way, is putting in another categorical variable here. So we'd end up with a three dimensional table, but you don't want to deal with that. It's too hard. We have a choice for statistics. Chi-squared is just fine for what I have here. These ones, the comparative measures, including the confidence intervals, only apply when you have what's called a two by two table. And that means two rows and two columns. We have three rows and two columns. So these ones don't apply to what we're doing. We have some other choices. We can get a contingency coefficient or a phi and Kramer's V. Let's hit a contingency coefficient. And that's like a correlation coefficient here at the bottom. We can do some ordinal statistics. We have categorical data, not ordinal. So I'm going to leave that alone. And then we have some choices about what we put in the table. Now right now, what we have are just observed frequencies, the number of states that fall into each combination. We can also put expected frequencies. And that's important because that's what the Chi-squared test is comparing these observed values to. So for instance, up here in Friendly and Conventional, we have four states with Democrat governors. But if the data were completely randomly distributed, it would be seven and a half. On the other hand, down here, we have eight states that are temperamental and uninhibited and have Republican governor. But we would expect if things were random to have 9.63. The way it gets that by the way is by multiplying the column totals, by the row totals, and then dividing by the grand total for each of the cells. But the important part stays the same. Down here, we have our Chi-squared test, and we get a value of Chi-squared of 4.89. With two degrees of freedom, we have a probability value of 0.087. Now, that's something that's not very likely to happen by chance. But because it's greater than the standard cutoff of 0.05, we conclude that even with this really big difference right here, that these results are not statistically different from what we would expect through random variation. So even though it looks like there's a big difference, it doesn't hold up under null hypothesis testing. And that's one of the values of doing the Chi-squared test. Even something that looks at eyeball level like a big result, when you do the actual numbers and get the inferential test, it may tell you a different story, which is exactly what happened in this situation.