dummy_variables.pdf

Dummy Variables

Dummy Variables Program Transcript

DR. MATT JONES: Hi everybody, this is Dr. Matt Jones from the Center for Research Quality here to talk to you today about constructing dummy variables in SPSS. The purpose behind our conversation today is to show you how to construct these dummy variables to use as independent variables when you are fitting a multiple regression model or constructing a multiple regression model,

And I have in front of us the Afro barometer data set. I've greatly simplified it for the purpose of this demonstration. You'll see, there are obviously only three variables in it, country in alphabetical order, country by region, and trust in government index. Now I might want to construct a variable or use a variable, country by region, that that might be relevant to my research question or might be an important controlling variable that I need to use in my multiple regression analysis. And it's very tempting just to throw it in as an independent variable as it is here.

SPSS will allow me to do that. It will produce some output for that variable or coefficient so forth and associated p values. But the statistics generated really won't necessarily make any sense unless I'm creating a dummy variable or set of dummy variables from this original variable. So if I go and click on values here, you'll see that there are five 4 attributes or four groups to this variable country by region, West Africa, East Africa, Southern Africa, and North Africa.

And the rule is for creating dummy variables is the number of groups minus 1. That is there four groups here, four attributes to this variable. So I need to take 4 minus 1, obviously equals 3. I need to create three dummy variables. One variable is always left out if you will to service that reference category. And just again for the sake of simplicity, I'm going to leave number four, North Africa, as our reference category today.

What you pick as your reference category might be dependent upon your research question, some theory, what it is you're trying to find out, again, very context specific. But, again, for today, just going to sort of randomly choose North Africa as our reference category. Before you create your dummy variable, you do want to note the original coding on the original variable here one, two, three, and four and what those correspond to.

So let's go ahead and move out of here and create these variables. Transform, recode into different variables, this is how we're going to start our process of creating the dummy variables. Because we are creating new variables. So SPSS is asking, what's the input variable? You think of that as the original variable, country by region. Because we are going to pull this apart. So country by region is our original variable. Now let's create our first dummy variable, we'll call it West Africa.

© 2016 Laureate Education, Inc. 1

Dummy Variables

And for our label, we'll do the same. So I have to give it old and new values. So the old value for West Africa was 1, and the new value is going to be 1. And for dummy variables, they have to take on the attribute value of either 1 or 0. 1 it has a attribute, or 0 it doesn't. And hopefully that becomes just a little bit clearer as we walk through this process.

Now since I'm creating this dummy variable for West Africa, I've already told SPSS from that original variable, country by region, take all the West Africa cases and essentially flip that switch, turn them on to create this new West Africa dummy variable. All others turn off. Those are not West Africa.

So there are a couple different ways you can do that. I'm going to show you the what I would call quote, unquote the long way of doing this. So if we have to, remember we had three other groups to this variable. We had the old value of 2, which corresponded to East Africa, that's now going to be a 0. We had 3 which was southern Africa. Again, for our West Africa variable, it's going to be 0. Don't forget to hit add. In then four, North Africa, which is our reference category, 0. Add.

Now I could go ahead I could use the range. You know I could have just done 2 through 4 equals 0. That would have worked. Or I could've also done all other values and then put the new value in of zero. So that would have told SPSS, OK, take 1 equals 1. All others 0. The only thing to be just a little cautious about there it is if you have user defined or system defined missing values. They could possibly be thrown in there. Again, it depends upon this specific data set and how things are coded in there.

So that's why I'm just showing you what I call quote unquote the long way of doing it today. Go ahead click continue. Be sure and hit this radio icon change. Once you hit that, you'll see the OK is sort of activated. We can go ahead and create that variable. We'll see we'll get some SPSS syntax output here. And there it is. It says our variables been created. OK, so here it is West Africa.

Now we need to create two other dummy variables so that we have our three dummy variables here. So let's go ahead and see if we can quickly do this. So recode into different variables. One thing I always do is hit reset because everything you did before is still going to be in there, so I just do this so I don't confuse myself. Again, doing the same thing, country by region. Except this one I'm calling East Africa because I'm creating a separate dummy variable for East Africa.

OK, old and new value, so our old value for East Africa was 2. Now the new value is going to be 1. Remember dummy variables have to have the value 1, it has an attribute, or 0. So I'm saying, OK, all East Africa cases now turn into 1 for this dummy variable of the East Africa. Add. And 1, which was West Africa, is now going to be 0. I mean everything else is going to be 0, all others 0.

© 2016 Laureate Education, Inc. 2

Dummy Variables

Again four our reference category, and our reference category is going to be 0 in each of them. Hit continue. Sure, again, hit change. If you don't hit change, you'll see that OK will not sort of light up, if you will, for you. You have to go ahead, and there we go. Hit OK. And there's our output, it's been created. And one more. Recode into different variables, reset, again, country by region, our final variable, which is Southern Africa.

Old and New value, so in the old value, the original country by region that was coded as a 3, and now it's going to be coded as 1 because we're focusing on that Southern Africa dummy variable, add. And all others 0. And make sure we get our reference North Africa in here, 0. Change. OK.

So now we can see we have West Africa, East Africa, and Southern Africa set up as dummy variables. And if we go click down here, if we go to our data view, you'll see our original variable, country by region, so 1, remember 1, in the original variable corresponded to West Africa. And if we go over here and look at our West Africa variable, you see that for those cases where the original variable was 1, coded West Africa, is now also 1 for the West Africa dummy variable but 0 for East and Southern Africa.

And so if we go ahead and scroll down to East Africa, so here we go. So for cases where our original variable country by origin 2, remember that equaled East Africa, and still does in the original variable. But now if we go over to West Africa, 0, it's not West Africa, 1. It is East Africa. So for this dummy variable those things are matching up which is a good thing. And 0 for Southern Africa. Again, remember North Africa is serving as our reference category.

So now we've created dummy variables, we can go ahead and use them in a linear regression analysis. So let's just go ahead and run a very quick linear regression. So I've gone ahead and already entered those variables in here. I'm just going to use, we don't have many variables to work with, so we're just going to trust and government as our dependent variable. And only use these, again, just for the sake of demonstration these categorical dummy variables as independent variables. Click OK.

So by this point, you're probably very familiar with the output around model summary and the ANOVA, let's go ahead and look at the coefficients. You'll see here now that we have each of these dummy variables represented. And so we can go ahead and interpret these coefficients, these un-standardized coefficients. And what these un-standardized coefficients are representing is a value in reference to the reference category, to North Africa.

So for instance, West Africa, the un-standardized coefficient there, 1.289, that is saying compared to North Africa, there's a difference in West Africa of 1.289 units or our dependent variable is trust in government measured on this index.

© 2016 Laureate Education, Inc. 3

Dummy Variables

So there's a difference in trust in government of 1.289 units on that index compared to North Africa.

And we can go and an interpret the same for East Africa and southern Africa, those un-standardized coefficients are in comparison to the North Africa means. So it's the West Africa mean for trust in government being compared to the North Africa mean. So it's really what we're looking at here is the difference between those means of West Africa, North Africa, East Africa, and North Africa, and Southern Africa, and North Africa, again, the means. And that's how you create dummy variables in SPSS.

© 2016 Laureate Education, Inc. 4