POLI 279 MEASUREMENT THEORY
Seventh Assignment
Due 30 May 2007
11049990999 0USA 100 CLINTON 55 17 6 99 0.733 -0.587 0.065 21041509041 1ALABAMA 20000CALLAHAN 563 58 15 503 0.853 0.729 0.043 31042930041 2ALABAMA 20000EVERETT 571 70 21 502 0.825 0.746 0.041 41041563241 3ALABAMA 10000BROWDER 459 89 120 462 0.664 -0.037 0.015 51041100041 4ALABAMA 10000BEVILL 438 121 108 462 0.660 -0.081 0.015 61042910041 5ALABAMA 10000CRAMER 470 97 116 480 0.662 -0.023 0.014 71042930141 6ALABAMA 20000BACHUS 602 32 34 488 0.856 0.689 0.036 81042930241 7ALABAMA 10000HILLIARD 457 121 34 504 0.726 -0.643 0.023 91041406681 1ALASKA 20000YOUNG, DON 519 49 31 466 0.814 0.592 0.031 101042950061 1ARIZONA 20000SALMON 615 37 45 468 0.840 0.816 0.045 etc etc etc etc etc etcThe legislator coordinates are in the next to the last column (shown in red). For example, former President Clinton's coordinate is -0.587. Use R to make a smoothed histogram of the Republicans and Democrats in the 104th House using the estimated coordinates above (the party code is shown in blue). Use arrows to show the locations of former President Clinton and former Speaker of the House Newt Gingrich.
HOU104KH.ORD Name of Data File NOMINAL MULTIDIMENSIONAL UNFOLDING Title of Run 1321 1 5 Number RCs, Left on 1st, Up on 2nd 1 36 Number Dimensions, Number Characters to Read From Header 15.0000 0.5000 Starting Values for BETA and WEIGHT 0.0250 20 RC Min. Cutoff, Number RCs for Legislator (36A1,3600I1) Format for Roll Call File (1x,I4,36A1,1X,4i4,51f7.3) Format for Legislator Coordinate File -- NOM31.DAT (1x,I4,36A1,1X,51f7.3) Format for H-S Coordinate File -- FORT.34The red "1" in the fourth line is the number of dimensions. This is the number you should change to "2". Leave everything else in the file the same! Run W-NOMINATE on the 104th House in two dimensions. Turn in the NOM21.DAT output file.
11049990999 0USA 100 CLINTON 54 17 7 99 0.729 -0.594 -0.116 0.066 0.129 21041509041 1ALABAMA 20000CALLAHAN 561 36 17 525 0.880 0.758 0.653 0.042 0.132 31042930041 2ALABAMA 20000EVERETT 569 50 23 522 0.852 0.774 0.634 0.040 0.132 41041563241 3ALABAMA 10000BROWDER 473 35 106 516 0.733 -0.034 0.842 0.015 0.083 51041100041 4ALABAMA 10000BEVILL 448 57 98 526 0.723 -0.079 0.759 0.015 0.075 61042910041 5ALABAMA 10000CRAMER 474 46 112 531 0.710 -0.018 0.688 0.015 0.064 71042930141 6ALABAMA 20000BACHUS 597 25 39 495 0.861 0.695 0.232 0.035 0.078 81042930241 7ALABAMA 10000HILLIARD 445 117 46 508 0.748 -0.642 0.417 0.023 0.046 91041406681 1ALASKA 20000YOUNG, DON 517 34 33 481 0.839 0.600 0.583 0.031 0.122 101042950061 1ARIZONA 20000SALMON 623 35 37 470 0.842 0.826 -0.119 0.045 0.075 etc etc etc etc etc etcThe legislator coordinates are are the third and fourth columns from the end (shown in red). For example, former President Clinton's coordinates are -0.594 and -0.116. Use R to plot the legislators in two dimensions. Use "D" for Non-Southern Democrats, "S" for Southern Democrats, "R" for Republicans, and "P" for President Clinton. This graph should be in the same format as the one you did for question 2.f of Homework 5.
SEN104KH.ORD NOMINAL MULTIDIMENSIONAL UNFOLDING OF 104TH SENATE 919 1 22 2 36 11 Number Dimensions, Number Characters to Read from Header, Number of Bootstrap Trials 15.0000 0.5000 0.0250 20 (36A1,15000I1) (1x,I4,36A1,1X,4i4,51f7.3) (I4,1X,36A1,80F10.4)It is identical to the NOMSTART.DAT used in question 1 above except for the "11" (colored red) in the fourth line of the file. This is the number of bootstrap trials. Normally it is set to 1001 but we will use 101 in this problem.
1 1049990999 0USA 10000CLINTON -0.9160 -0.3336 -0.8668 -0.2853 0.1039 0.2095 1.0000 0.1436 0.1436 1.0000 2 1041470541 0ALABAMA 10000HEFLIN -0.3923 -0.2917 -0.3546 -0.4203 0.0510 0.1876 1.0000 0.7794 0.7794 1.0000 3 1049465941 0ALABAMA 20000SHELBY 0.5858 -0.3131 0.6871 -0.3176 0.1162 0.0603 1.0000 0.2238 0.2238 1.0000 4 1041490781 0ALASKA 20000MURKOWSKI 0.6600 -0.1009 0.7623 -0.0338 0.1138 0.1090 1.0000 0.0790 0.0790 1.0000 5 1041210981 0ALASKA 20000STEVENS 0.4199 -0.3162 0.5695 -0.3110 0.1645 0.1222 1.0000 0.1487 0.1487 1.0000 etc etc etc 98 1044930873 0WASHING 10000MURRAY -0.9235 -0.1667 -0.8936 -0.1832 0.0555 0.0916 1.0000 -0.1436 -0.1436 1.0000 99 104 136656 0WEST VI 10000BYRD, ROBER -0.6504 -0.5292 -0.6249 -0.6165 0.0465 0.1304 1.0000 0.1703 0.1703 1.0000 100 1041492256 0WEST VI 10000ROCKEFELLER -0.8080 -0.0714 -0.7819 -0.0967 0.0416 0.1585 1.0000 0.6202 0.6202 1.0000 101 1044930925 0WISCONS 10000FEINGOLD -0.8300 0.5577 -0.7844 0.6024 0.0546 0.0564 1.0000 0.6076 0.6076 1.0000 102 1041570325 0WISCONS 10000KOHL -0.6772 0.5656 -0.6449 0.7452 0.0395 0.1934 1.0000 0.5894 0.5894 1.0000 103 1041471068 0WYOMING 20000SIMPSON 0.3605 -0.4309 0.5124 -0.4402 0.1725 0.1322 1.0000 0.4797 0.4797 1.0000 104 1041563368 0WYOMING 20000THOMAS 0.7165 0.3480 0.7850 0.3535 0.0824 0.1281 1.0000 0.5629 0.5629 1.0000The legislator coordinates are are the first two columns after the name of the legislator (shown in red). For example, former President Clinton's coordinates are -0.9160 and -0.3336.
# # Plot_Bootstrap_New.r -- Program reads parametric bootstrap files posted # at http://voteview.org/Lewis_and_Poole.htm # and plots the legislator ideal points and the # standard errors # # Remove all objects just to be safe # rm(list=ls(all=TRUE)) # library(MASS) library(stats) library(ellipse) You Will Need to Download and Install this Library # # Set up to read Parametric Bootstrap File # rc.file <- "c:/ucsd_homework_7/fort.26" # # The variable fields and their widths # rc.fields <- c("counter","cong","id","state","dist","lstate","party", "eh1","eh2","name","wnom1","wnom2","wnom1bs","wnom2bs", "se1","se2","r11","r12","r21","r22") # # Note -- For some files the field widths will be (e.g., H108_BS_1000_2.DAT): # (5,3,5,2,2,7,4,1,1,11,8,7,7,7,7,7,7) # rc.fieldWidths <- c(4,4,5,2,2,7,4,1,1,11,10,10,10,10,10,10,10,10,10,10) # # Read the vote data from fwf (FIXED WIDTH FORMAT -- FWF) # TT <- read.fwf(file=rc.file,widths=rc.fieldWidths,as.is=TRUE,col.names=rc.fields) party <- TT[,7] state <- TT[,4] wnom1 <- TT[,11] wnom2 <- TT[,12] std1 <- TT[,15] std2 <- TT[,16] corr12 <- TT[,18] # nrow <- length(TT[,1]) ncol <- length(TT[1,]) # plot(TT[,11],TT[,12],type="n",asp=1, main="", xlab="", ylab="", xlim=c(-1.0,1.0),ylim=c(-1.0,1.0),font=2) points(wnom1[party == 100 & state >= 40 & state <= 51],wnom2[party == 100 & state >= 40 & state <= 51],pch='S',col="red") points(wnom1[party == 100 & state == 53],wnom2[party == 100 & state == 53],pch='S',col="red") points(wnom1[party == 100 & state == 54],wnom2[party == 100 & state == 54],pch='S',col="red") points(wnom1[party == 100 & (state < 40 | state > 54)],wnom2[party == 100 & (state < 40 | state > 54)],pch='D',col="red") points(wnom1[party == 100 & state == 52],wnom2[party == 100 & state == 52],pch='D',col="red") points(wnom1[party == 200],wnom2[party == 200],pch='R',col="blue") # Main title mtext("104th Senate From W-NOMINATE\nWith Bootstrapped Standard Errors",side=3,line=1.50,cex=1.2,font=2) # x-axis title mtext("Liberal - Conservative",side=1,line=2.75,cex=1.2) # y-axis title mtext("Social/Lifestyle Issues",side=2,line=2.5,cex=1.2) # # # This code does the cross-hairs for the standard errors. If the # correlation is greater than .15 between the two dimensions, # the 95% confidence ellipse is shown # for (i in 1:nrow) { # # These two statements do the cross-hairs # lines(c(wnom1[i],wnom1[i]),c(wnom2[i]-1.96*std2[i],wnom2[i]+1.96*std2[i]),col="gray") lines(c(wnom1[i]-1.96*std1[i],wnom1[i]+1.96*std1[i]),c(wnom2[i],wnom2[i]),col="gray") # # This if statement does the ellipse # if (abs(corr12[i]) > .15){ lines(ellipse(x=corr12[i],scale=c(std1[i],std2[i]), centre=c(wnom1[i],wnom2[i])), col="gray") } } #Run this program and turn in the plot. It should look similar to this:
1 1049990999 0USA 10000CLINTON -0.3160 -0.7979 -0.8467 -0.2906 0.5711 0.5775 0.1089 0.2070 1.0000 -0.8322 -0.8322 1.0000 2 1041470541 0ALABAMA 10000HEFLIN -0.2219 0.0278 0.0011 -0.2066 0.3139 0.3403 0.1975 0.2220 1.0000 -0.9512 -0.9512 1.0000 3 1049465941 0ALABAMA 20000SHELBY 0.6878 -0.0150 0.7162 -0.1751 0.0633 0.1796 0.0529 0.0582 1.0000 -0.3841 -0.3841 1.0000 4 1041490781 0ALASKA 20000MURKOWSKI 0.7285 -0.0996 0.7283 -0.0236 0.0781 0.0929 0.0741 0.0445 1.0000 -0.5790 -0.5790 1.0000 5 1041210981 0ALASKA 20000STEVENS 0.6308 -0.1836 0.6209 -0.2080 0.0682 0.0844 0.0639 0.0763 1.0000 -0.4706 -0.4706 1.0000 etc etc etc 98 1044930873 0WASHING 10000MURRAY -0.8772 -0.0015 -0.9068 -0.1126 0.0506 0.1520 0.0378 0.0919 1.0000 0.0408 0.0408 1.0000 99 104 136656 0WEST VI 10000BYRD, ROBER -0.6919 -0.5972 -0.6128 -0.3697 0.0959 0.2762 0.0448 0.1300 1.0000 -0.7018 -0.7018 1.0000 100 1041492256 0WEST VI 10000ROCKEFELLER -0.7673 -0.0990 -0.7713 -0.1318 0.0585 0.0952 0.0554 0.0842 1.0000 0.2288 0.2288 1.0000 101 1044930925 0WISCONS 10000FEINGOLD -0.9161 0.3985 -0.8439 0.3498 0.0901 0.1056 0.0457 0.0875 1.0000 0.7287 0.7287 1.0000 102 1041570325 0WISCONS 10000KOHL -0.6915 0.2468 -0.7519 0.4653 0.1107 0.2343 0.0859 0.0404 1.0000 -0.2221 -0.2221 1.0000 103 1041471068 0WYOMING 20000SIMPSON 0.5253 -0.1192 0.5113 -0.0559 0.0463 0.1029 0.0417 0.0743 1.0000 -0.3008 -0.3008 1.0000 104 1041563368 0WYOMING 20000THOMAS 0.7193 0.1231 0.7215 0.1730 0.0458 0.1302 0.0434 0.1130 1.0000 -0.4295 -0.4295 1.0000The average legislator coordinates are are the third and fourth columns after the name of the legislator (shown in red). For example, former President Clinton's coordinates are -0.8467 and -0.2906.
# # wnominate_in_R.r # # Program to Run R Version of W-NOMINATE # # # Remove all objects just to be safe # rm(list=ls(all=TRUE)) # library(pscl) library(wnominate) # # sen88 <- readKH("https://legacy.voteview.com/k7ftp/sen88kh.ord", dtl=NULL, yea=c(1,2,3), nay=c(4,5,6), missing=c(7,8,9), notInLegis=0, desc="88th U.S. Senate", debug=FALSE) # result <- wnominate(sen88, polarity=c(7,3)) # write.table(result$legislators,"c:/ucsd_homework_7/wnomkeith_88x.txt") #
# # idealKeith_2007.r -- Implements Simon's IDEAL in R # rm(list=ls(all=TRUE)) # library(pscl) # s104 <- readKH("https://legacy.voteview.com/k7ftp/sen104kh.ord",dtl=NULL, yea=c(1,2,3), nay=c(4,5,6), missing=c(7,8,9), notInLegis=0, desc="104th U.S. Senate", debug=FALSE) class(s104) csts <- constrain.legis(s104,x=list("KERRY (D MA)"=-1, "HELMS (R NC)"=1),d=1) kpideal <- ideal(s104, priors=csts, startvals=csts, store.item=TRUE) sumkpideal <- summary(kpideal,include.beta=TRUE) # write.table(sumkpideal$x,"c:/ucsd_homework_7/tab_simon_104x.txt") write.table(sumkpideal$bResults,"c:/ucsd_homework_7/tab_simon_104z.txt") #The tab_simon2_104x.txt file has the esimated legislator ideal points in a format similar to those from MCMCPack that you estimated for question 1 of Homework 6. The file should look something like this: