So now that I've described multi-dimensional scaling, I want to show you the process and are. We're going to look at traditional multi-dimensional scaling by reducing the number of dimensions down to a predefined number. To use this command, the classical multidimensional scaling command, which is denoted cmds scale() the parameters that you need are K or the number of dimensions and then eig value which shows you the Eig values. If you choose to see them. The data set we're going to use is contained in R. It's called eurodist and it has a matrix of the distances between European cities. I sort of want to talk about this for a second. So here you have a Athens to Athens and obviously the distance between those two cities is zero. But from Athens to Barcelona its 3,313 kilometers etc. So this has all the distances. If you are given a table like this, you can imagine that if you had a pencil and a ruler and a compass you could somehow recreate this map. So you could arbitrarily pick a point, let's say it's Athens and say there's Athens, and then Barcelona is 3,313 kilometers away. So you might take a compass and draw a circle around that. Let's draw a circle, and that should be in the middle. But somewhere Barcelona lies in that circle. Then you can see Brussels is 2,900 kilometers away from Athens, but it's also if you look at Barcelona and Brussels it's 1,300 kilometers away from Barcelona. So again by triangulating you can sort of figure out the possibilities and then over time fill in the map. Okay. Note that this doesn't necessarily orient your map in the right direction, but you will have at least the spatial relationship between the cities and a pretty good idea of that. Then you'll get some sort of output, here's a table of let's call them longitude and latitude coordinates. So latitude-longitude coordinates. They're not the actual longitude and latitude. They're just numbers on a scale and where to put things. So that's where we're going to come up with. So let's do that. So for this example, you're going to need to make sure you have installed and loaded the stats Library. So let me just run that code. There we go. Then we're going to attain the data you're dist. We're going to make sure that's a matrix. So there it is and you can see here it has 21 rows and 21 columns. Let me look at that data real quick. So here's the Eurodist table, and here are the distances, Athens to itself is obviously zero kilometers. Whereas Barcelona, Athens is 3,300 plus kilometers etc. So this just has the distances between two cities. The command is really simple. Again, we're going to use this technique of putting the results of a function into a variable. In this case the variable name is MDS. Oftentimes if it's regression you'll see something like fit. Here's the function command CAN classical multi-dimensional scale. So that's what cmds stands for. The data set is euro distance. K is equal to two, and I've turned off the eig values. These are the required parameters, and we're going to have two dimensions. So let's just run these commands Data. Run the multidimensional scaling. So now we've run it and we can look at this variable, and you can see here we have these two columns of data. So Athens has these x and y coordinates. Think of it that way 2,200 and 1,798 etc. In order to plop them, I'm going to put them into these two variables x and y, x y. So the first column will be going into X. The second column will go into why. Ignore this comment for now, I'll show you what that means in a second. So basically what these two lines 14 and 15 do is take column one and put that into x column two, and put that into y. X and y. Now I can plot them. So let me plot them. There they are. So these are based on that data set, that table of distances. This is what the output of the multidimensional scaling. It came out with these data points. So these are the relative distances as noted. I can add the city titles on here. Let me expand that a little bit so it's easier to see. There you have it. Here's the distance between Lisbon and Madrid, Barcelona and Madrid. Here's Marseilles, Stockholm here is at the bottom. So one thing you might have noticed if you're familiar with European geography is that Stockholm is actually toward the north, and Athens up here which is at the top of the map is really at the south. So in order to correct that one little issue, I'm going to invert the y-axis by subtracting it from zero and now if I plot that, put the labels on. You can see that Athens is at the bottom, Stockholm's at the north. I think this has a pretty good representation of the major cities of Europe, and I think if you looked at a national map and this map, you'll see that the dots line up pretty accurately. So just to wrap up, I want to note some of the the limitations of the simple example that I showed you. But that is not to say that multidimensional scaling is restricted to these two-dimensional examples. The first thing I want to mention is there's this data set here which was the map of the distances between two cities. Here it's just really point-to-point. You can imagine instead of having cities, you could have brands of soft drinks, or brands of potato chips or cookies or whatever you want. Then ask do you prefer brand A over brand B. Brand B over Brand C. So that would be a rank order preference. You can also ask them to put it on some sort of numerical scale. If you're trying to get a more granular understanding of their preferences and you don't have to have just these rank orders. You could have multiple dimensions in terms of. If there were some sort of cookie, you could ask about sweetness, texture, color, flavors etc. So you can have a number of dimensions that are reduced down to two dimensions. Then that's where the interpretation comes in. So if he found that color, brown, sweetness, high sweetness, sort of a brownish color cookie with frosting are preferred. You might actually look at those. Brands of cookies and say these are the chocolate cookies with some sort of icing. Whereas there is another group of cookies that are sort of lightened flavor, delicate crisp. They might be another class of cookies that you recognize, and then by looking at consumer preferences you can identify people in those various groups. So that's a very brief rundown of multi-dimensional scaling. But once you understand these basic concepts the other forms of multidimensional scaling are just as easy to interpret and run. So I hope you enjoyed this video.