R: create an object of class rollcall

rollcall {pscl} | R Documentation

## create an object of class rollcall

### Description

Create a `rollcall` object, used for the analysis of legislative voting or, equivalently, item-response modeling of binary data produced by standardized tests, etc.

### 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 to roll calls (test items). `data` can also be a `list` with an element named `votes` containing the matrix described above.
`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` or `data.frame` and has a component named `legis.names`, then this will be used. Names will be generated if not supplied, or if there are fewer unique names supplied than legislators/subjects (rows of the roll call matrix).
`vote.names` | a vector of names or labels for the votes or items. If `data` is a `list` or `data.frame` and has a component named `vote.names`, then this will be used. Names will be generated if not supplied, or if there are fewer unique names supplied than votes/test-items (columns of the roll call matrix).
`legis.data` | a `matrix` or `data.frame` containing covariates specific to each legislator/test-taker; e.g., party affiliation, district-level covariates. If this object does not have the same number of rows as `data`, an error is returned.
`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 indicating the type of vote. If this object does not have the same number of row as the number of columns in `data`, an error is returned.
`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.

### Details

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

### Value

An object of class `rollcall`, a list with the following components:

`votes` | a `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.
`codes` | a `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.
`n` | numeric, number of legislators, equal to `dim(votes)[1]`
`m` | numeric, number of votes, equal to `dim(votes)[2]`
`legis.data` | user-supplied data on legislators/test-subjects.
`vote.data` | user-supplied data on rollcall votes/test-items.
`desc` | any user-supplied description. If no description was provided, defaults `desc` defaults to `NULL`.
`source` | any user-supplied source information (e.g., a url or a short-form reference). If no description is provided, `source` defaults to `NULL`.

### 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

    ## 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)

    ## Not run:
    ## 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)

    ## End(Not run)

[Package pscl version 1.5.2 Index]