Learn R Programming

pscl (version 0.5)

rollcall: Create an object of class rollcall

Description

create a rollcall object

Usage

rollcall(data,
         yea=1, nay=0, missing=NA, notInLegis=9,
         legis.names=NULL, vote.names=NULL,
         legis.data=NULL, vote.data=NULL,
         desc=NULL, source=NULL)

Arguments

data
voting decisions (for roll calls), or test results (for IRT). Can be in one of two forms. First, data may be a matrix, with rows corresponding to legislators (subjects) and columns
yea
numeric, possibly a vector, code(s) for a Yea vote in the rollcall context, or a correct answer in the educational testing context. Default is 1.
nay
numeric, possibly a vector, code(s) for a Nay vote in the rollcall context, or an incorrect answer in the educational testing context. Default is 0.
missing
numeric or NA, possibly a vector, code(s) for missing data. Default is NA.
notInLegis
numeric or NA, possibly a vector, code(s) for the legislator not being in the legislature when a particular roll call was recorded (e.g., deceased, retired, yet to be elected).
legis.names
a vector of names of the legislators or individuals. If data is a list and contains an element named legis.names, then the list element will be used. Names will be generated if not supplied.
vote.names
a vector of names or labels for the votes or items. If data is a list and contains an element named vote.names, then the list element will be used. Names will be generated if not supplied.
legis.data
a matrix or data.frame containing covariates specific to each legislator/test-taker; e.g., party affiliation, district-level covariates. If this o
vote.data
a matrix or data.frame containing covariates specific to each roll call vote or test item; e.g., a timestamp, the bill sponsor, descriptive text in
desc
character, a string providing an (optional) description of the data being used. If data is a list and contains an element named desc, then this will be used.
source
character, a string providing an (optional) description of where the roll call data originated (e.g., a URL or a short-form reference). Used in print and summary methods.

Value

  • An object of class rollcall, a list with the following components:
  • votesa matrix containing voting decisions, with rows corresponding to legislators (test subjects) and columns to roll call votes (test items). Legislators (test subjects) and items (or votes) have been labeled in the dimnames attribute of this matrix, using the legis.names and/or vote.names arguments, respectively.
  • codesa list with named components yea, nay, notInLegis and missing, each component a numeric vector (possibly of length 1 and possibly NA), indicating how entries in the votes component of the rollcall object should be considered. This list simply gathers up the values in the yea, nay, notInLegis and missing arguments passed to the function.
  • nnumeric, number of legislators, equal to dim(votes)[1]
  • mnumeric, number of votes, equal to dim(votes)[2]
  • legis.datauser-supplied data on legislators/test-subjects.
  • vote.datauser-supplied data on rollcall votes/test-items.
  • descany user-supplied description. If no description was provided, defaults desc defaults to NULL.
  • sourceany user-supplied source information (e.g., a url or a short-form reference). If no description is provided, source defaults to NULL.

Details

See below for methods that operate on objects of class rollcall.

See Also

readKH for creating objects from files (possibly over the web), in the format used for data from the United States Congress used by Keith Poole and Howard Rosenthal (and others).

summary.rollcall, ideal for model fitting.

Examples

Run this code
## generate some fake roll call data
set.seed(314159265)
fakeData <- matrix(sample(x=c(0,1),size=5000,replace=TRUE),
                   50,100)
rc <- rollcall(fakeData)
is(rc,"rollcall")        ## TRUE
rc                       ## print the rollcall object on screen

data(sc9497)             ## Supreme Court example data
rc <- rollcall(data=sc9497$votes,
               legis.names=sc9497$legis.names,
               desc=sc9497$desc)
summary(rc,verbose=TRUE)                      

## s107
## could use readKH for this
dat <- readLines("sen107kh.ord")
dat <- substring(dat,37)
mat <- matrix(NA,ncol=nchar(dat[1]),nrow=length(dat))
for(i in 1:103){
  mat[i,] <- as.numeric(unlist(strsplit(dat[i],
                                        split=character(0))))
}

s107 <- rollcall(mat,
                 yea=c(1,2,3),
                 nay=c(4,5,6),
                 missing=c(7,8,9),
                 notInLegis=0,
                 desc="107th U.S. Senate",
                 source="http://voteview.ucsd.edu")
summary(s107)

Run the code above in your browser using DataLab