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
Supplemental Movie Assignment
Due 11 June 2008


In this problem we are going to make a movie of the output of the Parametric Bootstrap W-NOMINATE Program. The output files for Houses and Senate 1 to 108 are on the Parametric Bootstrap Output page.

Below is the R program and the two data files used to make this movie showing 1001 Bootstrap estimates of President Bush in the 108th Senate:

Bootstrap_Movie_Evil_Bush.mov -- 243 Megabytes!

parametric_bootstrap_movie.r -- Program to make jpegs for Movie
parametric_bootstrap_movie.r looks like this:
#
# Parametric_bootstrap_movie.r -- Does Two-Dim Plot of the bootstrap trials
#                           for any Member of Congress 1789 - 2004 (Congresses
#                           1 - 108)
#
#  
#  Remove all objects just to be safe
#
rm(list=ls(all=TRUE))
#
#
library(MASS)
library(pcurve)
library(stats)
library(ellipse)
#
ncong <- 108         Select the Senate
ntrials <- 1001
#
#  Select Senator here
#
# ICPSR/Poole-Rosenthal ID Number
#
idnoselect <- 99910  Use the ID Number of Senator You Want to Display
#
# Position in the file
#
iselect <- 1         The Senator's row in the Data
#
#  Read bootstrap Means and Standard Deviations
#
rcx.file <- "c:/ucsd_homework_movie/s108_bs_1000_2.dat"  This is the Summary File Showing the Bootstrapped Standard Errors
#
# Standard fields and their widths 
#
rcx.fields <- c("counter","cong","idno","state","cd","statename","party","ecodes",
                   "membername","x1","x2","x1bmean","x2bmean","se1","se2","r12") 
rcx.fieldWidths <- c(5,3,5,2,2,7,4,2,12,9,10,10,10,10,10,10)
#    
# Read the vote data from fwf
#
T <- read.fwf(file=rcx.file,widths=rcx.fieldWidths,as.is=TRUE,col.names=rcx.fields)
#
#
nrowtarget <- length(T[,1])
ncoltarget <- length(T[1,])
#
#  Read Bootstrap Trials
#
rcx.file <- "c:/ucsd_homework_movie/s108_nom31_1000.dat"  This is the output matrix for the
#                                                         trials.  It has 1001 trials all stacked up
#                                                         top of each other -- 1001 NOM31.DAT
# Standard fields and their widths                        files stacked up
#
rcx.fields <- c("counter","cong","idno","state","cd","statename","party","ecodes",
                   "membername","k11","k12","k21","k22","gmp","x1","x2","se1","se2") 
rcx.fieldWidths <- c(5,3,5,2,2,7,4,2,12,4,4,4,4,7,7,7,7,7)
#    
# Read the vote data from fwf
#
TTT <- read.fwf(file=rcx.file,widths=rcx.fieldWidths,as.is=TRUE,col.names=rcx.fields)
#
#
nrowstrials <- length(TTT[,1])
ncolstrials <- length(TTT[1,])
#
TBOOT <- TTT[TTT[,3]==idnoselect,]   This pulls the 1001 sets of coordinates out for the 
#                                             selected Senator
#
#  Loop Over Bootstrap trials
#
iiii <- 0
while (iiii < ntrials) {
#
iiii <- iiii + 1
fnum <- iiii
  if(fnum<10)
    fn <- paste("000",fnum,sep="")
  else if(fnum<100)                    This block of statements guarantees the the Jpegs
    fn <- paste("00",fnum,sep="")       get written out from 0001.jpg to 9999.jpg
  else if(fnum<1000)
    fn <- paste("0",fnum,sep="")
  else
    fn <- fnum
#
#
#  Pull Coordinate from Bootstrap Mean File
#
xtrial1 <- T[iselect,10]    Selected Senator's Coordinate used to make Black Dot Below
xtrial2 <- T[iselect,11]
#
  jpeg(file=paste("C:/ucsd_homework_movie/JPG_ANI/",fn,".jpg",sep=""),  This is the Jpeg Write Statement
       width=1165,height=651,quality=100,pointsize=12, bg = "white")      Note the Path Statement
#
par(mfrow=c(1,2))         Creates Two Graphic Panels Side-by-Side
#
#
# mar
# A numerical vector of the form c(bottom, left, top, right) which 
# gives the number of lines of margin to be specified on the four 
# sides of the plot. The default is c(5, 4, 4, 2) + 0.1.
#
#
par(mar=c(4.1,4.1,4.1,2.1))   Nice Margins
#
plot(T[,10],T[,11],type="n",asp=1,main="",
       xlab="",
       ylab="",
       xlim=c(-1.0,1.0),ylim=c(-1.0,1.0),
       cex=1.2,font=2)
#
# Main title
#                         Note the Use of the Paste Command Here
mtext(paste("Senate ", ncong, "\n", 1787+2*ncong, "-",  1787+2*ncong+1, sep=""),side=3,line=1.25,cex=1.2,font=2)
#
# x-axis title
mtext("Liberal - Conservative",side=1,line=2.25,cex=1.2,font=2)
# y-axis title
mtext("Social Issues",side=2,line=2.25,cex=1.2,font=2)
#
#  Southern Democrats
points(T[T[,7] == 100 & T[,4] >= 40 & T[,4] <= 51,10],T[T[,7] == 100 & T[,4] >= 40 & T[,4] <= 51,11],pch='S',col="red",font=2)
points(T[T[,7] == 100 & T[,4] == 53,10],T[T[,7] == 100 & T[,4] == 53,11],pch='S',col="red",font=2)
points(T[T[,7] == 100 & T[,4] == 54,10],T[T[,7] == 100 & T[,4] == 54,11],pch='S',col="red",font=2)
#  Northern Democrats
points(T[T[,7] == 100 & (T[,4] < 40 | T[,4] > 54),10],T[T[,7] == 100 & (T[,4] < 40 | T[,4] > 54),11],pch='D',col="red",font=2)
points(T[T[,7] == 100 & T[,4] == 52,10],T[T[,7] == 100 & T[,4] == 52,11],pch='D',col="red",font=2)
#  Republicans
points(T[T[,7] == 200,10],T[T[,7] == 200,11],pch='R',col="blue",font=2)
#  Presidents
points(T[T[,4] == 99,10],T[T[,4] == 99,11],pch='P',col="black",font=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:nrowtarget) {                   This Code Block is From Parametric Bootstrap
#                                             Plotting Program Used in Homework 6
#  These two statements do the cross-hairs    The Left Panel Always Shows the Bootstrap Results --
#                                             Cross-Hairs and Ellipses
lines(c(T[i,10],T[i,10]),c(T[i,11]-1.96*T[i,15],T[i,11]+1.96*T[i,15]),col="gray")
lines(c(T[i,10]-1.96*T[i,14],T[i,10]+1.96*T[i,14]),c(T[i,11],T[i,11]),col="gray")
#
#  This if statement does the ellipse
#
  if (abs(T[i,16]) > .30){
     lines(ellipse(x=T[i,16],scale=c(T[i,14],T[i,15]),
     centre=c(T[i,10],T[i,11])),
     col="gray")
  }
}
#
#
# mar
# A numerical vector of the form c(bottom, left, top, right) which 
# gives the number of lines of margin to be specified on the four 
# sides of the plot. The default is c(5, 4, 4, 2) + 0.1.
#
par(mar=c(4.1,4.1,4.1,2.1))
#
#
#
plot(T[,10],T[,11],type="n",asp=1,main="",
       xlab="",
       ylab="",
       xlim=c(-1.0,1.0),ylim=c(-1.0,1.0),
       cex=1.2,font=2)
#
# Main title    Note that the Title has a Counter for the Trials
#
mtext(paste("Bootstrap Trial ", iiii, "\n", "President Bush"),side=3,line=1.25,cex=1.2,font=2)
#
# x-axis title
mtext("Liberal - Conservative",side=1,line=2.25,cex=1.2,font=2)
# y-axis title
#mtext("Social Issues",side=2,line=2.25,cex=1.2,font=2)
#
#  Southern Democrats
points(T[T[,7] == 100 & T[,4] >= 40 & T[,4] <= 51,10],T[T[,7] == 100 & T[,4] >= 40 & T[,4] <= 51,11],pch='S',col="red",font=2)
points(T[T[,7] == 100 & T[,4] == 53,10],T[T[,7] == 100 & T[,4] == 53,11],pch='S',col="red",font=2)
points(T[T[,7] == 100 & T[,4] == 54,10],T[T[,7] == 100 & T[,4] == 54,11],pch='S',col="red",font=2)
#  Northern Democrats
points(T[T[,7] == 100 & (T[,4] < 40 | T[,4] > 54),10],T[T[,7] == 100 & (T[,4] < 40 | T[,4] > 54),11],pch='D',col="red",font=2)
points(T[T[,7] == 100 & T[,4] == 52,10],T[T[,7] == 100 & T[,4] == 52,11],pch='D',col="red",font=2)
#  Republicans
points(T[T[,7] == 200,10],T[T[,7] == 200,11],pch='R',col="blue",font=2)
#  Presidents
points(T[T[,4] == 99,10],T[T[,4] == 99,11],pch='P',col="black",font=2)
#
#  Plot Bootstrap Trial
#
points(TBOOT[1:iiii,15],TBOOT[1:iiii,16],pch=16,col="purple",font=2)  With Each Jpeg You have to Write all the previous trials up through the current one
points(xtrial1,xtrial2,pch=16,col="black",cex=1.3,font=2) This Puts a Black Dot on the Position of the Senator
#
dev.off()              # turn off the postscript device
}
After the program runs it creates 0001.jpg to 1001.jpg and stores them in C:/ucsd_homework_movie/JPG_ANI/. To make the movie, open QuickTime and in the file menu there is an option "Open Image Sequence:



Click on "Open Image Sequence" and do the usual WINDOZE path selection until you get to where the jpegs are stored:



Highlight 0001.jpg and note that the default number of frames per second is 30. With 1001 jpegs that means your movie will last about 30 seconds. Note that there is a dropdown menu there and you can change the speed. I left it at 30 seconds:



After you click "Open" QuickTime reads in the 1001 jpegs and brings up a rough draft of the movie. You can click on play and look at it but if the size is large it may appear "jerky". If you are satisfied with the results click on the file menu "Save as":



and you see this:



Name the movie and use the automatically selected "Save as self-contained movie" option:



You will then see this -- be patient, sometimes this takes a while!





  1. (75 Points) Select a Senate and a Senator (do not use the 108th) and make a movie of the Senator's bootstrap trials. If you use Senates prior to the 96th consult with me about the proper labeling of the axes. If you want to use a Senate from the 19th Century you will need more token options for the party codes. You can find them is this program:

    hs_all_dwnom_movie_2008.r -- Program to make Movie of DW-NOMINATE

  2. (50 Points) Extra Credit for Creativity!! Put it to music and put in on YouTube!