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.

POLI 277 MEASUREMENT THEORY
Fifth Assignment
Due 21 May 2008

1. The aim of this problem is to familarize you with my Optimal Classification (OC) program. Download the program and the "control card" file:

PERFL_2006.EXE -- Maximum Classification Scaling Program
and place them in the same folder on a WINDOZE machine. PERFSTRT_2006.DAT looks like this:
```SEN110KH_1ST.ORD
NON-PARAMETRIC MULTIDIMENSIONAL UNFOLDING OF 110th SENATE
2  442   20   36   10    9   20 0.005    5
(36A1,25000I1)
(I5,1X,36A1,2I5,50F8.3)
```
The first line is the roll call data file, the second line is the title, the third line, in order, is the number of dimensions, the number of roll calls, the number of iterations (leave as is), the number of "characters" to read off the front of each legislator's record (leave as is), the record number of a Senator that you believe is on the "Left" (this just sets "liberal" on the left -- lower ranks or negative values on the first dimension if the scaling is in two or more dimensions -- and "conservative" on the right), and the record number of a Senator that you believe is on "Up" or on positive side of the second dimension (in the U.S. context, these are the Southern Democrats in an earlier era). The last line is the format for the coordinate output file. Please study the examples on the Optimal Classification Program page because we will be using this program several more times!

1. At the command line type

PERFL_2006

The program should only take a few seconds to run and it produces three output files -- PERF21.DAT, PERF23.DAT, and PERF25.DAT. PERF21.DAT should look something like this:
```
12 MAY       2008  22.11.31.43.
RANDOM NUMBER SEED     51700
SEN110KH_1ST.ORD
NON-PARAMETRIC MULTIDIMENSIONAL UNFOLDING OF 110th SENATE
2  442   20   36   10    9   20 0.005    5
(36A1,25000I1)
(I5,1X,36A1,2I5,50F8.3)
******************************************************************************
1 ROLL CALLS   2    2580   36950  0.06982  0.93018  0.78625           0.00000
LEGISLATORS  2    2483   36950  0.06720  0.93280  0.79428  0.00000
2 ROLL CALLS   2    2421   36950  0.06552  0.93448  0.79942           0.99617
LEGISLATORS  2    2409   36950  0.06520  0.93480  0.80041  0.99945
3 ROLL CALLS   2    2401   36950  0.06498  0.93502  0.80108           0.99955
LEGISLATORS  2    2398   36950  0.06490  0.93510  0.80133  0.99981
4 ROLL CALLS   2    2393   36950  0.06476  0.93524  0.80174           0.99983
LEGISLATORS  2    2392   36950  0.06474  0.93526  0.80182  0.99988
5 ROLL CALLS   2    2390   36950  0.06471  0.93529  0.80199           0.99982
LEGISLATORS  2    2386   36950  0.06457  0.93543  0.80232  0.99689
6 ROLL CALLS   2    2382   36950  0.06447  0.93553  0.80265           0.99975
LEGISLATORS  2    2379   36950  0.06438  0.93562  0.80290  0.99916
7 ROLL CALLS   2    2376   36950  0.06430  0.93570  0.80315           0.99983
LEGISLATORS  2    2372   36950  0.06419  0.93581  0.80348  0.99960
8 ROLL CALLS   2    2357   36950  0.06379  0.93621  0.80472           0.99892
LEGISLATORS  2    2357   36950  0.06379  0.93621  0.80472  0.99998
9 ROLL CALLS   2    2354   36950  0.06371  0.93629  0.80497           0.99979
LEGISLATORS  2    2354   36950  0.06371  0.93629  0.80497  0.99999
10 ROLL CALLS   2    2353   36950  0.06368  0.93632  0.80505           0.99991
LEGISLATORS  2    2352   36950  0.06365  0.93635  0.80514  0.99934
11 ROLL CALLS   2    2335   36950  0.06319  0.93681  0.80655           0.99839
LEGISLATORS  2    2334   36950  0.06317  0.93683  0.80663  0.99852
12 ROLL CALLS   2    2325   36950  0.06292  0.93708  0.80737           0.99903
LEGISLATORS  2    2325   36950  0.06292  0.93708  0.80737  0.99999
13 ROLL CALLS   2    2324   36950  0.06290  0.93710  0.80746           0.99981
LEGISLATORS  2    2324   36950  0.06290  0.93710  0.80746  0.99999
14 ROLL CALLS   2    2324   36950  0.06290  0.93710  0.80746           0.99975
LEGISLATORS  2    2324   36950  0.06290  0.93710  0.80746  0.99997
15 ROLL CALLS   2    2324   36950  0.06290  0.93710  0.80746           0.99977
LEGISLATORS  2    2324   36950  0.06290  0.93710  0.80746  1.00000
16 ROLL CALLS   2    2321   36950  0.06281  0.93719  0.80771           0.99979
LEGISLATORS  2    2320   36950  0.06279  0.93721  0.80779  0.99992
17 ROLL CALLS   2    2317   36950  0.06271  0.93729  0.80804           0.99955
LEGISLATORS  2    2317   36950  0.06271  0.93729  0.80804  0.99999
18 ROLL CALLS   2    2317   36950  0.06271  0.93729  0.80804           0.99975
LEGISLATORS  2    2317   36950  0.06271  0.93729  0.80804  1.00000
19 ROLL CALLS   2    2317   36950  0.06271  0.93729  0.80804           0.99978
LEGISLATORS  2    2317   36950  0.06271  0.93729  0.80804  1.00000
20 ROLL CALLS   2    2316   36950  0.06268  0.93732  0.80812           0.99972
LEGISLATORS  2    2316   36950  0.06268  0.93732  0.80812  0.99999
MEAN VOLUME LEG.   0.0056   0.0073
MACHINE PREC.   2    2316   36950  0.06268  0.93732  0.80812
MACHINE PREC.   2    2316   36950  0.06268  0.93732  0.80812
22.11.31.43.
ELAPSED TIME OF JOB  22.12.20.73.```
The seventh column reports the correct classification. For the 110th Senate (2007) the algorithm quickly converges to 0.93732 (93.7%).

Turn in a copy of this file.

2. The file PERF25.DAT contains the output coordinates for the Senators and the roll calls. The first few lines of PERF25.DAT for the Senators should look very similar to this:
```
12 MAY       2008  22.11.31.43.
1 1109991099 0USA     200  BUSH           2   67   0.970   0.025   0.294   0.317
2 1104970041 0ALABAMA 20001SESSIONS      26  377   0.931   0.002   0.238  -0.251
3 1109465941 0ALABAMA 20001SHELBY        34  387   0.912   0.004   0.212  -0.201
4 1104030081 0ALASKA  20001MURKOWSKI     19  382   0.950   0.002   0.111   0.041
5 1101210981 0ALASKA  20001STEVENS       29  374   0.922   0.002   0.108  -0.039
6 1101542961 0ARIZONA 20001KYL           27  381   0.929   0.002   0.284   0.387
7 1101503961 0ARIZONA 20001MCCAIN         7  165   0.958   0.004   0.289   0.456
8 1104030142 0ARKANSA 10001PRYOR         22  388   0.943   0.002  -0.151  -0.212
9 1102930542 0ARKANSA 10001LINCOLN       23  370   0.938   0.003  -0.179  -0.003
10 1101501171 0CALIFOR 10001BOXER         11  365   0.970   0.026  -0.261   0.095
etc etc etc```
The last two columns are the two-dimensional coordinates. The party code is just to the right of the state name: 100=Democrat, 200=Republican. The state codes are to the left of the column of zeroes at the beginning of the state names.

The first few lines of PERF25.DAT for the Roll Calls (just below the Senators) should look very similar to this:
```
1    2  93   2   2 102   0 1 6  0.000  0.350  0.984 -0.175
2    3  56  40   4  58  44 1 6  0.900  0.128  0.997  0.078
3    4  54  41  24  71  31 1 6  0.415  0.207  0.994 -0.106
4    5  46  51  15  47  55 1 6  0.674 -0.030  0.725  0.689
5    6  25  72   7  77  25 6 1  0.720  0.228  0.999 -0.050
6    7  90   6   2  97   5 1 6  0.667  0.307  0.999  0.040
7    9  81   6   4  99   3 1 6  0.333  0.346  0.909 -0.417
8   12  95   2   1 100   2 1 6  0.500  0.346  0.906 -0.422
9   13  89   5   1  97   5 1 6  0.800  0.302  0.995 -0.103
10   14  51  46   7  48  54 6 1  0.848 -0.162  0.967  0.253
etc etc etc```
The last two columns are the Normal Vector coordinates two-dimensional and the column immediately to the left of the Normal Vector Coordinates is the position on the Normal Vector where the Cutting Plane intersects.

Make a two-dimensional plot of the Cutting Planes and the Senator coordinates using the R program below:

plot_oc_output_X_and_Z.r -- R Program to Plot OC Cutting Line and Legislator Outputs

Use Epsilon to create the two files from PERF25.DAT that the R program reads. When you run the program you should see:

The "P" is President Bush. Modify the program to display the names of a few prominent Senators. Turn in the graph.

3. The file PERF23.DAT has some miscellaneous diagnostics for the program including the eigenvalues of the double-centered agreement score matrix. Here is the relevant portion of the file:
```
etc.
etc.
PERFORMANCE INDEX EIGENVALUE/VECTOR ROUTINE=    2  102    0     0
1   10.0801   66.8196   66.8196   12.1443   57.6262   57.6262
2    0.4663    3.0911   69.9107    0.9325    4.4249   62.0510
3    0.3578    2.3716   72.2823    0.6366    3.0205   65.0716
4    0.2290    1.5179   73.8002    0.3785    1.7962   66.8678
5    0.2153    1.4272   75.2275    0.3681    1.7464   68.6142
6    0.1868    1.2385   76.4659    0.3205    1.5207   70.1349
7    0.1460    0.9678   77.4337    0.3064    1.4537   71.5886
8    0.1087    0.7203   78.1540    0.2661    1.2628   72.8514
9    0.0986    0.6534   78.8074    0.2235    1.0605   73.9119
10    0.0948    0.6285   79.4359    0.1978    0.9387   74.8506
11    0.0876    0.5810   80.0169    0.1932    0.9165   75.7671
12    0.0738    0.4890   80.5059    0.1874    0.8892   76.6563
13    0.0716    0.4750   80.9809    0.1778    0.8436   77.4999
14    0.0650    0.4306   81.4115    0.1652    0.7837   78.2836
15    0.0616    0.4086   81.8201    0.1571    0.7455   79.0292
16    0.0575    0.3812   82.2013    0.1539    0.7302   79.7594
17    0.0562    0.3727   82.5740    0.1485    0.7047   80.4641
18    0.0536    0.3551   82.9291    0.1404    0.6662   81.1302
19    0.0498    0.3302   83.2593    0.1372    0.6512   81.7815
20    0.0477    0.3162   83.5756    0.1322    0.6272   82.4086
etc.
etc.```
The second column with a first entry of 10.0801 are the eigenvalues. Make a graph of the eigenvalues like the one you did for Homework 3 Q.3.d. In particular, you can modify the code below to do this:
```nrow <- 10
plot(T[,1],T[,2],
xlab="",
ylab="",
main="",
type="n",xlim=c(1,10),ylim=c(0.0,1.0),axes=FALSE)
#
# Main title:   which side of the plot (1=bottom, 2=left, 3=top, 4=right).
mtext("Normalized Eigenvalues of Double-Centered\n Agreement Score Matrix for the 104th Senate",side=3,line=2.75,cex=1.2)
# x-axis title
mtext("Dimension",side=1,line=2.75,cex=1.2)
# y-axis title
mtext("Normalized Eigenvalue",side=2,line=2.5,cex=1.2)
#
#  I am tricking R to do a nice looking x-axis by forcing
#      the labels
#
axis(1,1:10,
labels=c(' 1',' 2',' 3',' 4',' 5',' 6',' 7',' 8',' 9','10'),
font=2,col.axis='black',cex.axis=1.2)
#  font switch:  1 corresponds to plain text,
#                2 to bold face, 3 to italic and 4 to bold italic
#  the at=NULL tells R to compute tick marks internally
axis(2,at=NULL,col.axis='black',cex.axis=1.2,font=2)
#
box()
points(T[,1],T[,2],pch=16,col="red")
lines(T[1:nrow,1],T[1:nrow,2],lty=1,lwd=3,col="blue")```

4. Use Epsilon to change the number of dimensions from 2 to 1 in PERFSTRT_2006.DAT and run PERFL_2006 again (be sure to save the output files from the two-dimensional run first!!!! -- they will be overwritten by the new ones!). PERF21.DAT should look something like this:
```
12 MAY       2008  23.39.47.31.
RANDOM NUMBER SEED     96100
SEN110KH_1ST.ORD
NON-PARAMETRIC MULTIDIMENSIONAL UNFOLDING OF 110th SENATE
1  442   20   36   10    9   20 0.005    5
(36A1,25000I1)
(I5,1X,36A1,2I5,50F8.3)
******************************************************************************
1 ROLL CALLS   1    3047   36950  0.08246  0.91754  0.74756
2 LEGISLATORS  1    2996   36950  0.08108  0.91892  0.75178  0.99851
3 ROLL CALLS   1    2936   36950  0.07946  0.92054  0.75675
4 LEGISLATORS  1    2920   36950  0.07903  0.92097  0.75808  0.99946
5 ROLL CALLS   1    2907   36950  0.07867  0.92133  0.75915
6 LEGISLATORS  1    2905   36950  0.07862  0.92138  0.75932  0.99991
7 ROLL CALLS   1    2902   36950  0.07854  0.92146  0.75957
8 LEGISLATORS  1    2901   36950  0.07851  0.92149  0.75965  0.99997
9 ROLL CALLS   1    2900   36950  0.07848  0.92152  0.75973
10 LEGISLATORS  1    2900   36950  0.07848  0.92152  0.75973  0.99999
11 ROLL CALLS   1    2900   36950  0.07848  0.92152  0.75973
12 LEGISLATORS  1    2900   36950  0.07848  0.92152  0.75973  1.00000
SHARPEN         2    2891   36950
SHARPEN         3    2882   36950
SHARPEN         4    2867   36950
SHARPEN         5    2862   36950
L-PERMUTATIONS  5    2862   36950  0.07746  0.92254  0.76288
23.39.47.31.
ELAPSED TIME OF JOB  23.42.59.98.```
The correct classification is now 92.254% (0.92254).

Turn in a copy of this file.

5. The PERF25.DAT file contains a rank ordering for the Senators and the roll calls. The first part of the file shows the Senators in rank order and then in the order that they appear in the roll call file with their ranking:
```
1 1104930925 0WISCONS 10001FEINGOLD      32  388   0.918   1.000
2 11014213 1 0CONNECT 10001DODD           8  247   0.968   2.000
3 11029147 6 0VERMONT 32801SANDERS       21  385   0.945   3.000
4 11040704 5 0RHODE I 10001WHITEHOUSE     7  387   0.982   4.000
5 11010808 3 0MASSACH 10001KENNEDY  ED   25  355   0.930   5.000
6 1101501171 0CALIFOR 10001BOXER         12  365   0.967   6.000
7 1102938924 0OHIO    10001BROWN         12  380   0.968   7.000
8 1104050221 0ILLINOI 10001OBAMA          7  240   0.971   8.000
9 11014920 3 0MASSACH 10001KERRY  JOHN   18  370   0.951   9.000
10 1102937312 0NEW JER 10001MENENDEZ      12  384   0.969  10.000
etc.
etc.
etc.
95 1102910862 0COLORAD 20001ALLARD        20  380   0.947  94.500
96 1102954847 0NORTH C 20001BURR          22  379   0.942  96.000
97 1102953765 0NEVADA  20001ENSIGN        29  376   0.923  97.000
98 1101542961 0ARIZONA 20001KYL           39  381   0.898  98.000
99 1101542453 0OKLAHOM 20001INHOFE        20  375   0.947  99.000
100 1109991099 0USA     200  BUSH           5   67   0.925 100.000
101 1102955553 0OKLAHOM 20001COBURN        20  356   0.944 101.000
102 1102993648 0SOUTH C 20001DEMINT        15  378   0.960 102.000
******************************************************************************
1 1109991099 0USA     200  BUSH           5   67   0.925 100.000
2 1104970041 0ALABAMA 20001SESSIONS      35  377   0.907  84.000
3 1109465941 0ALABAMA 20001SHELBY        38  387   0.902  76.000
4 1104030081 0ALASKA  20001MURKOWSKI     22  382   0.942  60.000
5 1101210981 0ALASKA  20001STEVENS       27  374   0.928  59.000
6 1101542961 0ARIZONA 20001KYL           39  381   0.898  98.000
7 1101503961 0ARIZONA 20001MCCAIN        18  165   0.891  94.500
8 1104030142 0ARKANSA 10001PRYOR         29  388   0.925  45.000
9 1102930542 0ARKANSA 10001LINCOLN       26  370   0.930  38.500
10 1101501171 0CALIFOR 10001BOXER         12  365   0.967   6.000
etc.
etc.
etc.
95 1104930873 0WASHING 10001MURRAY        11  384   0.971  23.500
96 110 136656 0WEST VI 10001BYRD  ROBER   42  379   0.889  44.000
97 1101492256 0WEST VI 10001ROCKEFELLER   25  367   0.932  41.000
98 1104930925 0WISCONS 10001FEINGOLD      32  388   0.918   1.000
99 1101570325 0WISCONS 10001KOHL          16  388   0.959  23.500
100 1104970668 0WYOMING 20001ENZI          28  376   0.926  92.000
101 1101563368 0WYOMING 20011THOMAS        10  134   0.925  85.000
102 1104070768 0WYOMING 20022BARASSO       14  198   0.929  91.000```
Note that below the legislators are the rank positions for the roll call cutting points.

Use R to plot the rank-ordering of the Senators (horizontal axis) against the first dimension from the two-dimensional run done above (vertical axis). In the graph display the Pearson correlation between the two in a fashion similar to the way I displayed the STRESS value for the Weisberg & Rusk candidate configuration in Homework 4 Q.1 (in R the command to compute a Pearson correlation is cor(x,y) where x and y are two vectors).

2. The aim of this problem is to familarize you with the R version of Optimal Classification (OC). Download the R program:

Run oc_in_R.r and you will get two output files oc_110_x.txt and oc_110_z.txt. They should look like this:
```"state" "icpsrState" "cd" "icpsrLegis" "party" "partyCode" "rank" "correctYea" "wrongYea" "wrongNay" "correctNay" "volume" "coord1D" "coord2D"
"BUSH (R USA)" "USA" 99 0 99910 "R" 200 99 18 2 1 45 0.009 0.65886453047793 -0.505299508116657
"SESSIONS (R AL)" "AL" 41 0 49700 "R" 200 84 181 13 19 143 0.00500000000000002 0.538382525902544 0.471026749443308
"SHELBY (R AL)" "AL" 41 0 94659 "R" 200 74 190 16 23 136 0.00200000000000003 0.458159785428316 0.629949786857981
"MURKOWSKI (R AK)" "AK" 81 0 40300 "R" 200 59 206 8 9 138 0.00200000000000000 0.227316040827251 -0.0271514617971497
"STEVENS (R AK)" "AK" 81 0 12109 "R" 200 58 191 13 13 136 0.00199999999999999 0.222549028468612 0.233676219604477
"KYL (R AZ)" "AZ" 61 0 15429 "R" 200 94 168 11 13 168 0.00200000000000007 0.610864541795004 -0.588314913848976
"MCCAIN (R AZ)" "AZ" 61 0 15039 "R" 200 90 84 2 5 68 0.00600000000000006 0.58330722169332 -0.630566379665869
"PRYOR (D AR)" "AR" 42 0 40301 "D" 100 48 210 17 9 130 0.00300000000000003 -0.312019326418573 0.436668210440689
etc. etc. etc.```
and
```"correctYea" "wrongYea" "wrongNay" "correctNay" "PRE" "normVector1D" "normVector2D" "midpoints"
"1" NA NA NA NA NA NA NA NA
"2" NA NA NA NA NA NA NA NA
"3" 54 2 2 38 0.9 0.999972952533325 -0.00735487605505673 0.227596085594717
"4" 48 18 6 23 0.414634146341463 0.988332641285725 0.152310834050576 0.425617920115808
"5" 39 6 7 45 0.717391304347826 0.791786118677804 -0.610798446518276 -0.223520628668488
"6" 20 1 5 71 0.76 0.999999226737237 0.00124359355455651 0.508047391853177
"7" 89 2 1 4 0.5 0.992601737834462 -0.121415773472834 0.652274795185395
"8" NA NA NA NA NA NA NA NA
"9" 80 4 1 2 0.166666666666667 0.999658129632965 -0.0261462016117433 0.657185086985982
etc. etc. etc. ```
1. Report the Pearson correlations between the corresponding first and second dimensions estimated by PERFL_2006 and OC in R.

2. Run OC in R in one dimension and report the Spearman correlation between the legislator ranks.

3. Turn in the results of the plot(result) command in R.

3. The aim of this problem is to familarize you with the Aldrich-McKelvey scaling program. Download the program and the 1968 data and "control card" files:

MCKALNEW.EXE -- Aldrich-McKelvey scaling program
and place them in the same folder on a WINTEL machine. Read the Aldrich-McKelvey scaling program page to see how to run the program.

Here are the first three lines of OLS68A.DAT.
```
1681  0 10  1  1  1  1  1 63  4  4  5  7  1  2  2  3  7  1  1
1124  0 10  1  0  0  0  1 82  1  1  4  4  1  1  1  1  4  1  5
78  5 10  1  0  1  1  1 78  2  1  5  7  4  5  5  6  6  7  5

The variables, in order, are:

RESPONDENT ID      = unique 4 digit number
PARTY ID           = 0 to 6 -- 0 = Strong Democrat
1 = Weak Democrat
2 = Lean Democrat
3 = Independent
4 = Lean Republican
5 = Weak Republican
6 = Strong Republican
RAW INCOME         = **do not use**
FAMILY INCOME      = income quintile 1 - 5
SEX                = 0 Man, 1 Woman
RACE               = 0 White, 1 Black
SOUTH              = 0 North, 1 South
EDUCATION          = 1 High School or less, 2 Some College, 3 College
AGE                = In Years
URBAN UNREST SCALE = Johnson, Humphrey, Nixon, Wallace, Self-Placement
VIETNAM SCALE      = Johnson, Humphrey, Nixon, Wallace, Self-Placement
VOTED              = 1 Voted, 5 Did Not Vote
```
Run the Aldrich-McKelvey scaling procedure using both the urban unrest and vietnam files. In particular, for the urban unrest scale here are the commands:

MCKALNEW
Control Card File Name? URBAN68.CTL
Data File Name? OLS68A.DAT
Output File Name? URBAN.PRN
Coordinate Output File Name? URBAN.DAT

The program reads URBAN68.CTL and OLS68A.DAT and writes the output files to disk. The coordinates for the political stimuli are in URBAN.PRN. In particular, here is the relevant portion of URBAN.PRN:
```    etc etc etc
******************************************************************************
PERFORMANCE INDEX=    0
EIGENVALUES
-1070.0801
-936.8338
-251.0831
0.0012
******************************************************************************
******************************************************************************
STIMULUS COORDINATES
LBJ      HHH      NIXON    WALLA
-0.3978  -0.4262   0.0116   0.8124  These are the coordinates
STIMULUS COORDINATES RAW DATA
-0.4087  -0.4229   0.0232   0.8084
******************************************************************************
CORRECTED GOODNESS OF FIT AND RAW FIT
0.0919      0.5075
etc etc etc```
1. Graph the scaled stimuli coordinates against each other using R -- that is, use the Vietnam coordinates as the horizontal axis and the Urban Unrest coordinates as the vertical axis. Use the names of the candidates and label the graph and the axes appropriately. Why do you think the plot looks the way it does?

2. Use Epsilon to merge the party ID variable from OLS68A.DAT into the coordinate output file. For example, here are the first few lines of the coordinate output file for the urban unrest scale:
```
LINE #  CASE # R POS   ALPHA    BETA    SCALED POS     RSQ
1   1681   1.0   -2.6243    0.5249   -2.0994    0.9994    0.9997
2   1124   1.0   -0.8831    0.3532   -0.5298    0.6790    0.8240
3     78   4.0   -0.9588    0.2557    0.0639    0.8992    0.9483
4    553   4.0   -1.2302    0.2895   -0.0724    0.6460    0.8037```
The second column is the respondent ID number. Use the respondent ID number to match OLS68A.DAT with the output file and insert the party ID code into the output file. After you have inserted the party code you can delete all the columns except the party code, BETA (you will need that for graphing), and the Scaled Position. If you have done everything correctly the first few lines of your file should look like this:
```
0     0.5249   -2.0994
0     0.3532   -0.5298
5     0.2557    0.0639
1     0.2895   -0.0724
1     0.2763    0.6907
1     1.3930   -0.3482
0     1.0597   -0.5298
0     0.2322   -0.3482
0     0.4371   -0.8742
5     0.3901    0.6827
0     0.0033    0.0050
0     0.2119   -0.5298
1     0.2624    0.2624
2     0.2938   -0.5142
1     0.2745    0.1373
etc.
etc.
etc.```
Write an Epsilon text macro that inserts the party variable into the coordinate file. In the macro, use a split screen and place the coordinate file in the top screen and OLS68A.DAT in the bottom screen. When you begin it should look like this:

The beginning of the text macro should look like this:
```
(define-macro "hw6" "C-U20C-F
C-U5C-BC-KC-YC-DC-AC-XC-Y
C-U3C-F
C-U4C-BC-KC-YC-DC-AC-XC-Y")```
Open up another window and put the above macro fragment in it and you should be here:

Finish constructing the macro and turn in the listing.

3. Read the above file into R and make smoothed histograms of the scaled positions of the respondents by party ID. For example, to make smoothed histograms of the Strong Democrats and Strong Republicans use this R Program:

Smoothed_Histogram_hw_6_2006.r -- R Program to Plot Strong Democrats and Strong Republicans on Urban Unrest Scale

Here is what Smoothed_Histogram_hw_6_2006.r looks like:
```#
#
#  Smoothed_Histogram_hw_6_2006.r -- Plots Strong Democrats and Strong Republicans on
#                            1968 Urban Unrest Scale
#
#
rm(list=ls(all=TRUE))
#
#
library(MASS)
#
T <- matrix(scan("C:/UCSD_Homework_6/urban_hw6.txt",0),ncol=3,byrow=TRUE)
#
#  Gore and Bush Voters
#
strong.democrat <- T[T[,1]==0 & T[,2] > 0,3]    Select Strong Democrats With Positive Betas
strong.republican <- T[T[,1]==6 & T[,2] > 0,3]  Select Strong Republicans With Positive Betas
#
DemShare <- length(strong.democrat)/(length(strong.democrat)+length(strong.republican))   These two commands just compute
RepShare <- length(strong.republican)/(length(strong.democrat)+length(strong.republican))  the proportions for the two Parties
#
demdens <- density(strong.democrat)   density computes kernel density estimates. (Also see bandwidth.)
demdens\$y <- demdens\$y*DemShare       This is a trick so that the two densities....
#
repdens   <- density(strong.republican)
repdens\$y <- repdens\$y*RepShare       ...will add to 1.0
#
ymax1 <- max(demdens\$y)
ymax2 <- max(repdens\$y)
ymax <- 1.1*max(ymax1,ymax2)
#
plot(demdens,main="",
xlab="",
ylab="",
xlim=c(-1.5,1.5),ylim=c(0,ymax),font=2)
lines(demdens,lwd=3,col="red")
lines(repdens,lwd=3,col="blue")
#
text( .50,0.800,"Red = Strong Democrats",col="red",font=2,cex=1.2)
text( .50,0.725,"Blue = Strong Republicans",col="blue",font=2,cex=1.2)
# Main title
mtext("Strong Party Identifiers\nFrom 1968 Urban Unrest 7-Point Scale",side=3,line=1.50,cex=1.2,font=2)
# x-axis title
mtext("Urban Unrest Scale Value",side=1,line=2.75,cex=1.2)
# y-axis title
mtext("Density",side=2,line=2.5,cex=1.2)
#
arrows(-.398, 0.06,-.398,0.0,length=0.1,lwd=3,col="red")
text(-.308,.08,"LBJ",font=2)
arrows(-.426, 0.06,-.426,0.0,length=0.1,lwd=3,col="red")
text(-.516,.08,"HHH",font=2)
arrows( .012, 0.13, .012,0.0,length=0.1,lwd=3,col="blue")
text( .000,.16,"Nixon",font=2)
arrows( .812, 0.13, .812,0.0,length=0.1,lwd=3,col="green")
text( .812,.18,"Wallace",font=2)
#
#    LBJ      HHH      NIXON    WALLA
#  -0.3978  -0.4262   0.0116   0.8124```
Here is the graph it produces:

Turn in this plot.

4. Similar to the above, make a graph for all Democrats (0,1,2) and all Republicans (4,5,6). Adjust the labeling accordingly and make certain that everything is neatly presented.

5. Similar to the above, make a graph for all Democrats (0,1,2) and all Republicans (4,5,6) for the Vietnam scale. Adjust the labeling accordingly and make certain that everything is neatly presented.

6. Similar to the above, make a graph for all Democrats (0,1,2), all Republicans (4,5,6), and Independents (4) for the Vietnam scale. Adjust the labeling accordingly and make certain that everything is neatly presented. To do this note that you will have to add code to compute IndShare and adjust everything so that the three smoothed histograms add up to 1.

4. The aim of this problem is to show you how to use metric unfolding to analyze thermometer scores. To do this you need to run a program that unfolds the thermometer scores. We are going to analyze the 1968 feeling thermometers. Download the the program, control card file, and data file and place them in the same directory.

MLSMU6.EXE -- Metric Unfolding Program
The 1968 Election Data file contains the same variables that we used above plus the voting information for the respondents. The variables are:
```
idno           respondent id number
partyid        strength of party id -- 0 to 6
income         raw income category
incomeq        income quintile -- 1 to 5
race           0 = white, 1 = black
sex            0 = man, 1 = woman
south          0 = north, 1 = south
education      1=HS, 2=SC, 3=College
age            age in years
uulbj          lbj position urban unrest
uuhhh          humphrey pos urban unrest
uunixon        nixon position urban unrest
uuwallace      wallace pos urban unrest
uuself         self placement urban unrest
vnmlbj         lbj pos vietnam
vnmhhh         hhh pos vietnam
vnmnixon       nixon pos vietnam
vnmwallace     wallace pos vietnam
vnmself        self placement vietnam
voted          1=voted, 5=did not vote
votedfor       who voted for -- 1 = humphrey, 2= nixon, 3=wallace
wallace        wallace therm
humphrey       humphrey thermometer
nixon          nixon thermometer
mccarthy       mccarthy thermometer
reagan         reagan thermometer
rockefeller    rockefeller thermometer
lbj            lbj thermometer
romney         romney thermometer
kennedy        robert kennedy thermometer
muskie         muskie thermometer
agnew          agnew thermometer
lemay          "bombs away with Curtis LeMay" thermometer
```
The control card file for the metric unfolding procedure is shown below. The first line has the name of the data file. The first number in the second line is the number of stimuli, the next two numbers are the minimum and maximum number of dimensions to estimate, and the "10" is the number of iterations.

The third line contains some "antique" options we will never use. The only numbers that matter on this line are the "4" which indicates the number of identifying characters to read off each line of the data file (e.g., the respondent id number), and the "2" at the end. This is the number of missing data codes which appear in the sixth line.

The first number in the fourth line is a tolerance value -- leave it as is. The next three numbers are parameters to transform the input data into squared distances. In this case, let amx=-.02, bmx=2.0, and cmx=2.0. The following equation transforms the thermometers into squared distances:

d2 = (amx*t+bmx)cmx

where t = input data. This formula takes a linear transformation of the input data to the power cmx. With amx = -.02, bmx = 2.0, and cmx = 2.0, this is equivalent to subtracting the thermometer score from 100, dividing by 50, and then squaring. This converts t from a 0-100 scale to a 4-0 scale. If the data, t, are distances, set amx = 1.0, bmx = 0.0, and cmx = 2.0. If the data are correlations, set amx = -1.0, bmx = 1.0, and cmx=2.0 or 1.0 if the correlations are initially regarded as unsquared or squared distances respectively.

The next value, "1.5", is the maximum absolute expected coordinate value on any dimension. It is used for plotting purposes. If the squared distances are confined to a 4-0 scale, xmax=1.5 is usually sufficient. The last two numbers, "0.0" and "100.0", are the minimum and maximum expected values of the input data. These are used to catch coding errors in the input data. Anything out of range is treated as missing data.

The fifth line is the format of the data file and the sixth line contains the missing data codes.

Finally, the last 12 lines are labels for the stimuli.
```OLS68B.DAT
12    2    2   10    0    0
1    1    0    4    2
.001  -0.02    2.0     2.0     1.5     0.0   100.0
(1X,4A1,60X,12F3.0)
98 99
WALLACE
HUMPHREY
NIXON
MCCARTHY
REAGAN
ROCKEFELLER
LBJ
ROMNEY
R.KENNEDY
MUSKIE
AGNEW
LEMAY   ```
1. Run MLSMU6. It will produce an output file called FORT.22. The first 20 lines look like this:
```
WALLACE          1.2646    0.5154  217.4823    0.5541 1242.0000
HUMPHREY        -0.5559    0.3738  114.7892    0.6968 1252.0000
NIXON            0.1480   -0.5415  123.2209    0.5319 1250.0000
MCCARTHY        -0.6251   -0.4938  151.8926    0.3854 1204.0000
REAGAN           0.3080   -0.8895  131.8091    0.4380 1212.0000
ROCKEFELLER     -0.5579   -0.5995  148.1413    0.3724 1229.0000
LBJ             -0.5223    0.4905  147.0334    0.5573 1253.0000
ROMNEY          -0.4736   -0.7866  111.3147    0.3434 1167.0000
R.KENNEDY       -0.4245    0.2351  148.8571    0.5418 1242.0000
MUSKIE          -0.6611    0.1660  126.0836    0.4862 1177.0000
AGNEW            0.2341   -0.8706  114.1418    0.4675 1180.0000
LEMAY            1.1901    0.4267  174.3242    0.4601 1188.0000
1681            -0.0285    0.2555    0.7918    0.6824   12.0000
1124            -0.1768    0.2692    1.4788    0.6992   12.0000
78             0.5707   -0.1514    3.5611    0.2141   12.0000
553             0.1376    0.1064    0.1597    0.7047    9.0000
7             0.2542    0.1235    1.2634    0.0116   12.0000
412             0.2781    0.0867    0.1024    0.6197   12.0000
631             0.5017    0.1088    1.1196    0.0742   12.0000
1316             0.2175   -0.5842    1.1568    0.8577   12.0000
etc etc etc
etc etc etc```
The first two columns after the names are the two dimensional coordinates. The first 12 lines are the coordinates for the political candidates and lines 13 onward are the coordinates for the respondents. Use R to plot the 12 candidates in two dimensions. This plot should be very similar to the one you did for Question 1 above.

2. Use Epsilon to insert the voted and voted for variables into FORT.22 (strip off the candidate coordinates first). Turn in the Epsilon macro you used to do the insertion and the first 20 lines of the file.

3. Use R to make two-dimensional plots of the Voters, Non-Voters, Humphrey Voters only, Nixon Voters only, and Wallace Voters only. For example, your Humphrey Voter plot should look something like this:

Label each plot appropriately and use solid dots to plot the respondents. Turn in all these plots.

5. The aim of this problem is to analyze the 2000 thermometer scores using metric unfolding in the same fashion as above. Download the control card file and data file and place them in the same directory.

UNFOLD_2000.CTL -- Control Card File for Metric Unfolding Program
ELEC2000.DAT -- 2000 Election Data

Here are the first four lines of ELEC2000.DAT.
```
10787  4  8  0  0  0  2 49  1   0  65  60  30  40  70  50 998 998  40  59  75  63  65  6  1  3  6  4  0  2
21271  2  6  0  1  0  2 35  1  50  50  50  50 997  50   0  50 997  50 100   0 100   0  4  4  2  6  8  0  0
40285  2  6  0  0  0  2 63  0  70  55  55  60  65  55  55  65  50  60  70  65  65  90  6  5  5  5  5  0  1
50191  6  6  0  1  0  2 40  1  50  40  80  60  60  80  70  50  70   0  20  90  70  70  6  2  2  6  4  0  2

The variables, in order, are:

RESPONDENT ID      = unique 8 digit number
PARTY ID           = 0 to 6 -- 0 = Strong Democrat
1 = Weak Democrat
2 = Lean Democrat
3 = Independent
4 = Lean Republican
5 = Weak Republican
6 = Strong Republican
FAMILY INCOME      = 1 to 22 - 1.   A. NONE OR LESS THAN \$4,999
2.   B. \$5,000-\$9,999
3.   C. \$10,000-\$14,999
4.   D. \$15,000-\$24,999
5.   E. \$25,000-\$34,999
6.   F. \$35,000-\$49,999
7.   G. \$50,000-\$64,999
8.   H. \$65,000-\$74,999
9.   J. \$75,000-\$84,999
10.  K. \$85,000-\$94,999
11.  M. \$95,000-\$104,999
12.  N. \$105,000-\$114,999
13.  P. \$115,000-\$124,999
14.  Q. \$125,000-\$134,999
15.  R. \$135,000-\$144,999
16.  S. \$145,000-\$154,999
17.  T. \$155,000-\$164,999
18.  U. \$165,000-\$174,999
19.  V. \$175,000-\$184,999
20.  W. \$185,000-\$194,999
21.  X. \$195,000-\$199,999
22.  Y. \$200,000 and over

RACE               = 0 White, 1 Black
SEX                = 0 Man, 1 Woman
SOUTH              = 0 North, 1 South
EDUCATION          = 1 High School or less, 2 Some College, 3 College
AGE                = In Years
MARRIED            = 0 Single, 1 Married

FEELING THERMOMETERS   (0 TO 100)

= CLINTON
= GORE
= BUSH
= BUCHANAN
= MCCAIN
= LIEBERMAN
= CHENEY
= HILLARY CLINTON
= DEMOCRATIC PARTY
= REPUBLICAN PARTY
= REFORM PARTY
= PARTIES IN GENERAL

LIBERAL-CONSERVATIVE  SCALE  (1=EXTREMELY LIBERAL, 2=LIBERAL, 3=SLIGHTLY LIBERAL,
4=MODERATE; MIDDLE OF THE ROAD, 5=SLIGHTLY CONSERVATIVE,
6=CONSERVATIVE, 7=EXTREMELY CONSERVATIVE)

= SELF-PLACEMENT
= CLINTON
= GORE
= BUSH
= BUCHANAN

PRE-POST INTERVIEW = 1 IF PRE-ELECTION INTERVIEW ONLY
VOTE CHOICE        = 0 NON-VOTER
= 1 GORE
= 2 BUSH
= 3 3RD PARTY
```
MLSMU6 expects to read UNFOLD.CTL!! Consequently, rename your current UNFOLD.CTL to UNFOLD_1968.CTL and then you can copy UNFOLD_2000.CTL to UNFOLD.CTL.

1. Run MLSMU6. It will produce an output file called FORT.22. The first 20 lines look like this:
```
CLINTON         -0.7879   -0.0317  153.1404    0.7198 1477.0000
GORE            -0.7133   -0.1701  112.1776    0.7061 1468.0000
BUSH             0.8234   -0.2492  149.4325    0.5889 1458.0000
BUCHANAN         0.4576    1.0536  178.0645    0.3114 1246.0000
NADER           -0.2737    0.7599  174.6307    0.2645 1094.0000
MCCAIN           0.2850   -0.6498  122.5794    0.3691 1182.0000
BRADLEY         -0.0780   -0.7509  106.1498    0.3689 1088.0000
LIEBERMAN       -0.3428   -0.6394  107.1314    0.4758 1096.0000
CHENEY           0.7002   -0.4687  107.9753    0.5099 1147.0000
HILLARY         -0.8617    0.0625  203.7540    0.6459 1466.0000
DEMPARTY        -0.6788   -0.1713  112.8208    0.6861 1453.0000
REPUBPARTY       0.8235   -0.3286  142.8395    0.5546 1447.0000
REFORMPTY        0.1644    1.0398  132.9094    0.3140 1128.0000
PARTIES          0.1949   -0.7946  158.0865    0.2290 1413.0000
1             0.3666   -0.0534    1.2943    0.3584   12.0000
2            -0.2740    0.6767    2.5447    0.5465   12.0000
4             0.0094    0.0645    0.8008    0.0000   14.0000
5             0.5073   -0.0010    1.3888    0.6249   14.0000
7             0.2719    0.0294    0.3600    0.5458   14.0000
8            -0.6582   -0.2931    1.8168    0.7683   14.0000
etc etc etc
etc etc etc```
Use R to plot the 14 stimuli in two dimensions. This plot should be similar in format to the ones you did for the 1968 configuration above.

2. Use Epsilon to insert the VOTE CHOICE variable into FORT.22 (strip off the candidate coordinates first). Turn in the Epsilon macro you used to do the insertion and the first 20 lines of the file.

3. Use R to make two-dimensional plots of the Voters, Non-Voters, Gore Voters only, and Bush Voters only. For example, your Gore Voter plot should look something like this:

Label each plot appropriately and use solid dots to plot the respondents. Turn in all these plots.

4. Use R to make smoothed histograms -- using the first dimension from the thermometer scaling -- of the Voters and Non-Voters only, and the Gore Voters, Bush Voters, and Non-Voters. For example, your Bush-Gore-NonVoters plot should look something like this:

Here is the trick for getting the percentage breakdown in the plot:
```#
text(-1.0,0.53,paste("Gore Voters ",
100.0*round(goreShare, 3)),col="red",font=2)
text(-1.0,0.5,paste("Bush Voters ",
100.0*round(bushShare, 3)),col="blue",font=2)
text(-1.0,0.47,paste("Non Voters  ",
100.0*round(nonShare, 3)),col="black",font=2)
#```
Turn in the R code and the plots.