LEGACY CONTENT. If you are looking for Voteview.com, PLEASE CLICK HERE

This site is an archived version of Voteview.com archived from University of Georgia on May 23, 2017. This point-in-time capture includes all files publicly linked on Voteview.com at that time. We provide access to this content as a service to ensure that past users of Voteview.com have access to historical files. This content will remain online until at least January 1st, 2018. UCLA provides no warranty or guarantee of access to these files.

Homework 1, POLS 8505: MEASUREMENT THEORY
Due 20 January 2015



  1. The aim of this problem is to familarize you with the smacof package in R.

    georgia.r -- R Program

    georgia.txt -- Distances Data

    1. Run the program and turn in the plot.

    2. Note that R has chopped off one of the names on the left side. We can fix this by telling R to change the scale of the axes. To do this change the following line:

      xlim=c(-axismax-0.1,axismax),ylim=c(-axismax,axismax),font=2)

      Turn in the above plot.

  2. Continuing with the plotting exercise:

    1. Produce a nice plot of the cities by adjusting the positions of the names in the namepos[] vector and the offset control. Turn in this plot.

    2. The Cities are clearly in the wrong orientation. Note that, because we are dealing with distances, the configuration recovered by smacof is only going to be identified up to a choice of origin and a rotation. In general, a rotation matrix in two dimensions is:


      Where Q is the angle in radians. You can rotate the coordinates clockwise p/4 radians (45 degrees) with this code fragment:
      
         pi <- 3.141592653589793
         pi4 <- pi/4
         dimension1 <- cos(pi4)*xx + sin(pi4)*(-1.0)*yy
         dimension2 <- sin(pi4)*(-1.0)*xx + cos(pi4)*(-1.0)*yy
      Note that I have flipped the sign on the second dimension in the formula above.

      Use the above formula to rotate your configuration until it makes sense, properly label the X and Y axes by changing the labels in "mtext", and neatly arrange the city names. Turn in the Plot.

  3. Download the data file:

    U. S. Map Driving Distance Data

    The data file is reproduced below. It contains the lower half of a driving distance matrix computed between 10 U.S. cities -- Atlanta, Boise, Boston, Chicago, Cincinnati, Dallas, Denver, Los Angeles, Miami, and Washington, D.C..
    
    Atlanta         0000 2340 1084  715  481  826 1519 2252  662  641
    Boise           2340 0000 2797 1789 2018 1661  891  908 2974 2480
    Boston          1084 2797 0000  976  853 1868 2008 3130 1547  443
    Chicago          715 1789  976 0000  301  936 1017 2189 1386  696
    Cincinnati       481 2018  853  301 0000  988 1245 2292 1143  498
    Dallas           826 1661 1868  936  988 0000  797 1431 1394 1414
    Denver          1519  891 2008 1017 1245  797 0000 1189 2126 1707
    LosAngeles      2252  908 3130 2189 2292 1431 1189 0000 2885 2754
    Miami            662 2974 1547 1386 1143 1394 2126 2885 0000 1096
    WashingtonDC     641 2480  443  696  498 1414 1707 2754 1096 0000
    
    Run this data set through smacof and get the coordinates.

    1. Modify the georgia.r program to make a plot of the 10 U.S. Cities. Turn in a listing of the program and the two dimensional plot.

    2. Change metric=TRUE to metric=FALSE and run it through smacof (this tells smacof to do a Nonmetric MDS on dissimilarity data). Compare the Stress values for 1 to 3 dimensions with those obtained above and compare the two dimensional plot obtained with this option to that in part (a).


  4. In this problem we are going to do a classic non-metric MDS on the Morse Code data. Download data files:

    Morse Code Data Lower Half

    Morse Code Data Upper Half

    Here is what morse_code_U1.txt looks like:
    
    A  100   4   6  13   3  14  10  13  46   5  22   3  25  34   6   6   9  35  23   6  37  13  17  12   7   3   2   7   5   5   8   6   5   6   2   3
    B    4 100  37  31   5  28  17  21   5  19  34  40   6  10  12  22  25  16  18   2  18  34   8  84  30  42  12  17  14  40  32  74  43  17   4   4
    C    6  37 100  17   4  29  13   7  11  19  24  35  14   3   9  51  34  24  14   6   6  11  14  32  82  38  13  15  31  14  10  30  28  24  18  12
    D   13  31  17 100   7  23  40  36   9  13  81  56   8   7   9  27   9  45  29   6  17  20  27  40  15  33   3   9   6  11   9  19   8  10   5   6
    E    3   5   4   7 100   2   4   4  17   1   5   6   4   4   5   1   5  10   7  67   3   3   2   5   6   5   4   3   5   3   5   2   4   2   3   3
    F   14  28  29  23   2 100  10  29   5  33  16  50   7   6  10  42  12  35  14   2  21  27  25  19  27  13   8  16  47  25  26  24  21   5   5   5
    G   10  17  13  40   4  10 100   6   5  22  33  16  14  13  62  52  23  21   5   3  15  14  32  21  23  39  15  14   5  10   4  10  17  23  20  11
    H   13  21   7  36   4  29   6 100  10  10   9  29   5   8   8  14   8  17  37   4  36  59   9  33  14  11   3   9  15  43  70  35  17   4   3   3
    I   46   5  11   9  17   5   5  10 100   3   5  16  13  30   7   3   5  19  35  16  10   5   8   2   5   7   2   5   8   9   6   8   5   2   4   5
    J    5  19  19  13   1  33  22  10   3 100  22  31   8   3  21  63  47  11   2   7   9   9   9  22  32  28  67  66  33  15   7  11  28  29  26  23
    K   22  34  24  81   5  16  33   9   5  22 100  33  10  12  31  14  31  22   2   2  23  17  33  63  16  18   5   9  17   8   8  18  14  13   5   6
    L    3  40  35  56   6  50  16  29  16  31  33 100   6   2   9  37  36  28  12   5  16  19  20  31  25  59  12  13  17  15  26  29  36  16   7   3
    M   25   6  14   8   4   7  14   5  13   8  10   6 100  62  11  10  15  20   7   9  13   4  21   9  18   8   5   7   6   6   5   7  11   7  10   4
    N   34  10   3   7   4   6  13   8  30   3  12   2  62 100   5   9   5  28  12  10  16   4  12   4  16  11   5   2   3   4   4   6   2   2  10   2
    O    6  12   9   9   5  10  62   8   7  21  31   9  11   5 100  37  35  10   3   4  11  14  25  35  27  27  19  17   7   7   6  18  14  11  20  12
    P    6  22  51  27   1  42  52  14   3  63  14  37  10   9  37 100  43  23   9   4  12  19  19  19  41  30  34  44  24  11  15  17  24  23  25  13
    Q    9  25  34   9   5  12  23   8   5  47  31  36  15   5  35  43 100  11   2   3   6  14  12  37  50  63  34  32  17  12   9  27  40  58  37  24
    R   35  16  24  45  10  35  21  17  19  11  22  28  20  28  10  23  11 100  16   2  23  23  62  14  12  13   7  10  13   4   7  12   7   9   1   2
    S   23  18  14  29   7  14   5  37  35   2   2  12   7  12   3   9   2  16 100   9  56  24  12  10   6   7   8   2   2  15  28   9   5   5   5   2
    T    6   2   6   6  67   2   3   4  16   7   2   5   9  10   4   4   3   2   9 100   8   5   4   2   2   6   5   5   3   3   3   8   7   6  14   6
    U   37  18   6  17   3  21  15  36  10   9  23  16  13  16  11  12   6  23  56   8 100  57  34  17   9  11   6   6  16  34  10   9   9   7   4   3
    V   13  34  11  20   3  27  14  59   5   9  17  19   4   4  14  19  14  23  24   5  57 100  17  57  35  10  10  14  28  79  44  36  25  10   1   5
    W   17   8  14  27   2  25  32   9   8   9  33  20  21  12  25  19  12  62  12   4  34  17 100  22  25  22  10  22  19  16   5   9  11   6   3   7
    X   12  84  32  40   5  19  21  33   2  22  63  31   9   4  35  19  37  14  10   2  17  57  22 100  48  26  12  20  24  27  16  57  29  16  17   6
    Y    7  30  82  15   6  27  23  14   5  32  16  25  18  16  27  41  50  12   6   2   9  35  25  48 100  23  26  44  40  15  11  26  22  33  23  16
    Z    3  42  38  33   5  13  39  11   7  28  18  59   8  11  27  30  63  13   7   6  11  10  22  26  23 100  16  21  27   9  10  25  66  47  15  15
    1    2  12  13   3   4   8  15   3   2  67   5  12   5   5  19  34  34   7   8   5   6  10  10  12  26  16 100  63  13   8  10   8  19  32  57  55
    2    7  17  15   9   3  16  14   9   5  66   9  13   7   2  17  44  32  10   2   5   6  14  22  20  44  21  63 100  54  20   5  14  20  21  16  11
    3    5  14  31   6   5  47   5  15   8  33  17  17   6   3   7  24  17  13   2   3  16  28  19  24  40  27  13  54 100  31  23  41  16  17   8  10
    4    5  40  14  11   3  25  10  43   9  15   8  15   6   4   7  11  12   4  15   3  34  79  16  27  15   9   8  20  31 100  42  44  32  10   3   3
    5    8  32  10   9   5  26   4  70   6   7   8  26   5   4   6  15   9   7  28   3  10  44   5  16  11  10  10   5  23  42 100  42  24  10   6   5
    6    6  74  30  19   2  24  10  35   8  11  18  29   7   6  18  17  27  12   9   8   9  36   9  57  26  25   8  14  41  44  42 100  69  14   5  14
    7    5  43  28   8   4  21  17  17   5  28  14  36  11   2  14  24  40   7   5   7   9  25  11  29  22  66  19  20  16  32  24  69 100  70  20  13
    8    6  17  24  10   2   5  23   4   2  29  13  16   7   2  11  23  58   9   5   6   7  10   6  16  33  47  32  21  17  10  10  14  70 100  61  26
    9    2   4  18   5   3   5  20   3   4  26   5   7  10  10  20  25  37   1   5  14   4   1   3  17  23  15  57  16   8   3   6   5  20  61 100  78
    0    3   4  12   6   3   5  11   3   5  23   6   3   4   2  12  13  24   2   2   6   3   5   7   6  16  15  55  11  10   3   5  14  13  26  78 100
    
    This is the famous morse code data. If you compare this file to morsekystsu.txt they are exactly the same except the matrix is transposed.

    1. Run morsekystsl.txt and morsekystsu.txt through smacof (be sure to use unique output file names) in 1 to 3 dimensions. To do this change:

      ndim=2 to

      ndim=1 and

      ndim=3.

      Report the Stress values for 1 to 3 dimensions for the two halves of the data.

    2. Make two-dimensional Plots for the two halves of the data (put the 26 letters and 10 integers before the corresponding coordinates). You can modify the georgia.r program to do this. Turn in the plots and the R code. Do the plots look the same?