Homework 12, POLS 8505: MEASUREMENT THEORY
Due 20 April 2015



  1. In this problem we are going to turn thermometer scores into roll call votes and scale them with Optimal Classification.

    Download the R program:

    Here is the code block that creates roll calls from Thermometer Comparisons
    nrollcall <- (nq*(nq-1))/2
    LDATA <- rep(0,np*nrollcall)
    dim(LDATA) <- c(np,nrollcall)
    for (i in 1:np){
    jj <- 0
    for (j in 1:(nq-1)){
      for (k in (j+1):nq){
      jj <- jj + 1
    #
        if(!is.na(T[i,j])){ 
          if(!is.na(T[i,k])){
    #
           if(T[i,j] > T[i,k])LDATA[i,jj]=1  If the Thermometers are equal then it is treated as missing data
           if(T[i,j] < T[i,k])LDATA[i,jj]=6
          }
        }
      }
    }
    }
    mode(LDATA) <- "double"
    #
    hr <- rollcall(LDATA,yea=1,nay=6,missing=0,notInLegis=9,
                 legis.names=NULL, vote.names=NULL, legis.data=NULL, vote.data=NULL,
                 desc=NULL, source=NULL)
    result <- oc(hr, dims=2, polarity=c(1,2))
    #
    Here is how to select just the cutting lines for Wallace
    #
    #  PLOT JUST THE WALLACE CUTTING LINES
    i <- 1
    #
    while (i <= 11){
    #
    etc. etc.
    Here is how to select just the cutting lines for Humphrey
    #
    #  PLOT THE HUMPHREY CUTTING LINES
    #
    kkk <- NULL
    kkk[1] <- 1
    kkk[2:11] <- 12:21  Humphrey's cutting lines are 1, and 12-21
    #
    for (iii in 1:11){
       i <- kkk[iii]
    #
    1. Run the program and turn in the pair of two panel plots that it produces.

    2. Turn in summary(result) NEATLY FORMATTED and report result$fits.

    3. Add the code necessary to do a third two panel plot showing the cutting lines for Nixon and LBJ. Turn in the plot and the short code block (similar to the one above for Humphrey) you used to get the cutting lines for Nixon and LBJ, respectively.

  2. We are going to explore some nice features of Simon Jackman's Ideal program for analyzing roll call data. Ideal is part of the pscl package that has many nice routines (see this pdf describing the package, 100 pages ).

    Download the R program:

    #
    rm(list=ls(all=TRUE))
    #
    library(pscl)
    #
    #
    hr <- readKH("ftp://k7moa.com/sen104kh.ord",
           dtl=NULL,
           yea=c(1,2,3),
           nay=c(4,5,6),
           missing=c(7,8,9),
           notInLegis=0,
           desc="104th Senate Roll Call Data",
           debug=FALSE)
    #
    # Call IDEAL
    #
    # parameter "normalize=FALSE" is default setting
    #
    result <- ideal(hr, d=1, normalize=FALSE, store.item=TRUE)
    #
    #  names(result)
    #  [1] "n"       "m"       "d"       "codes"   "x"       "beta"    "xbar"   
    #  [8] "betabar" "call"   
    #
    # object "result" is unidentified
    #
    # "tracex" is a nice function to plot MCMC output for specified legislators:
    #
    tracex(result,d=1,legis=c("HELMS","KENNEDY"))
    #
    # postProcess identifies the solution, default method is
    # via normalization
    #
    result_id <- postProcess(result,constraints="normalize")
    #
    #  names(result_id)
    #  [1] "n"       "m"       "d"       "codes"   "x"       "beta"    "xbar"   
    #  [8] "betabar" "call"   
    #
    windows()
    plot(result)
    windows()
    plot(result_id)
    #
    # The model is identified but signed incorrectly; we can also
    # achieve identification by setting coordinates of k+1 points:
    #
    result_id2 <- postProcess(result,constraints=list(KENNEDY=c(-1),HELMS=c(1)))
    #
    windows()
    plot(result_id2)
    #
    1. Run Ideal_104_senate.r and turn in all the plots that it makes.

    2. Turn in summary(result) NEATLY FORMATTED.

    3. Type the commands:

      result_id3 <- postProcess(result,constraints=list(BOXER=c(-1),INHOFE=c(1)))
      plot(result_id3)

      Turn in this plot. Which Political Party is the most dispersed (i.e., has the bigger variance in ideal points)?

  3. In this problem we are going to try Lewis and Poole's Parametric Bootstrap with WNOMINATE.

    Download the R program:

    1. Run wnominate_bootstrap.r and turn in the plot that it makes.

    2. Report result$fits.

    3. Turn in plot(result).

    4. Change the number of trials to 501 in:

      result <- wnominate(hr, dims=2, trials=51, polarity=c(7,2))

      repeat (a), (b), and (c).

  4. Continuing with Lewis and Poole's Parametric Bootstrap with WNOMINATE we are going to scale the 90th (1967-68) House and compare it to the 90th Senate.

    Download the R program:

    1. Run wnominate_bootstrap_h90.r and turn in the plot that it makes. Note that this is a two panel plot.

    2. Report result$fits.

    3. Turn in plot(result).

    4. Change the number of trials to 501 in:

      result <- wnominate(hr, dims=2, trials=51, polarity=c(2,15))

      repeat (a), (b), and (c).