I am trying to learn how to use MDS, and would like to know if there is a way to assign different colors to dots in accordance to their value on a given variable (like the one on the wiki site for MDS for voting distribution amongst representatives in the US: https://en.wikipedia.org/wiki/Multidimensional_scaling )
Additionally I was wondering if there is an easy way to interpret the meaning of the dimensions?
I am using Stata 15.1 for Windows 10 64-bit
So as a side project I decided to dive in an explore MDS, so I made the following fictional dataset, where var* is meant to represent how a person voted on a bill (1=for 0=abstain and -1=against).
Parties have been given a label, but have values from 1 to 6, the order is the same as for number 1-6.
Number | Name | var3 | var4 | var5 | var6 | Party |
1 | Alan | -1 | 1 | -1 | 0 | Liberal Alliance |
2 | James | 0 | 1 | 1 | 1 | Socialdemocrats |
3 | George | 1 | 0 | -1 | -1 | Democrats |
4 | Andrew | -1 | -1 | 0 | -1 | Republicans |
5 | Callen | 0 | 1 | 0 | 0 | Libertarians |
6 | Michael | 1 | 1 | 1 | 1 | Conservatives |
7 | Christopher | 1 | 0 | 0 | 1 | Liberal Alliance |
8 | Charles | -1 | -1 | 1 | 0 | Liberal Alliance |
9 | Toby | 1 | 0 | 1 | -1 | Liberal Alliance |
10 | Abraham | 0 | 0 | -1 | 1 | Socialdemocrats |
11 | Harry | 0 | 1 | 0 | 1 | Socialdemocrats |
12 | Albus | 1 | 1 | 0 | -1 | Democrats |
13 | Ron | 1 | 1 | 1 | 0 | Democrats |
Using the command:
Code:
mds var*, id(Name)
Array
I have then unsuccesfully tried to color code the persons according to their parties (so that Alan, Christopher, Charles and Toby are all colored, let's say, light blue, as they are all members of the Liberal Alliance, and James, Abraham and Harry are all covered red as they are members of the Socialdemocrats), by trying things inspired by scatterplot techniques like
Code:
mds var* if Party==1, id(Name) || mds var* if Party==2, id(Name) || mds var* if Party==3, id(Name)
I am also struggling to interpret the dimensions, now I realise that might have to do with the fact that I am using a constructed dataset. However looking at the values for Ron, he has 1, 1, 1 and 0, yet he is plotted at roughly (-1,-0.8), which frankly confuses me quite a lot, as I had expected him to be plotted close to (1,1).
Thank you in advance,
Zacharias.
0 Response to Confusion about MDS
Post a Comment