Package 'oc'

Title: Optimal Classification Roll Call Analysis Software
Description: Estimates optimal classification (Poole 2000) <doi:10.1093/oxfordjournals.pan.a029814> scores from roll call votes supplied though a 'rollcall' object from package 'pscl'.
Authors: Keith Poole [aut], Jeffrey Lewis [aut] , James Lo [aut], Royce Carroll [aut] , William May [aut, cre] , U.S. National Science Foundation [fnd] (NSF Grant SES-0611974)
Maintainer: William May <[email protected]>
License: GPL-2
Version: 1.2.1
Built: 2024-11-03 05:36:24 UTC
Source: https://github.com/wmay/oc

Help Index


Optimal Classification Roll Call Scaling

Description

oc is the function that takes a rollcall object and estimates nonmetric Optimal Classification scores with them.

Usage

oc(rcObject, dims=2, minvotes=20, lop=0.025, polarity, verbose=FALSE)

Arguments

rcObject

An object of class rollcall, from Simon Jackman's pscl package.

dims

integer, number of dimensions to estimate. Must be nonnegative and cannot exceed 10 dimensions.

minvotes

minimum number of votes a legislator must vote in for them to be analyzed.

lop

A proportion between 0 and 1, the cut-off used for excluding lopsided votes, expressed as the proportion of non-missing votes on the minority side. The default, lop=0.025, eliminates votes where the minority is smaller than 2.5 overwrites the lopsided attribute in the RC object inputted.

polarity

a vector specifying the legislator in the data set who is conservative on each dimension. For example, c(3,5) indicates legislator 3 is conservative on dimension 1, and legislator 5 is conservative on dimension 2. Alternatively, polarity can be specified as a string for legislator names found in legis.names (ie. c("Bush", "Gore")) if every legislative name in the data set is unique. Finally, polarity can be specified as a list (ie. list("cd",c(4,5))) where the first list item is a variable from the roll call object's legis.data, and the second list item is a conservative legislator on each dimension as specified by the first list item. list("cd",c(4,5)) thus specifies the legislators with congressional district numbers of 4 and 5.

verbose

logical, indicates whether bills and legislators to be deleted should be printed while data is being checked before ideal points are estimated.

Value

An object of class OCobject, with elements as follows:

legislators

data frame, containing all data from the old perf25.dat file about legislators. For a typical ocObject run with an ORD file read using readKH, it will contain the following:

  • stateState name of legislator.

  • icpsrStateICPSR state code of legislator.

  • cdCongressional District number.

  • icpsrLegisICPSR code of legislator.

  • partyParty of legislator.

  • partyCodeICPSR party code of legislator.

  • rankRank ordering of legislator on the first dimension, from lowest to highest.

  • correctYeaPredicted Yeas and Actual Yeas.

  • wrongYeaPredicted Yeas and Actual Nays.

  • wrongNayPredicted Nays and Actual Yeas.

  • correctNayPredicted Nays and Actual Nays.

  • volumeMeasure of the legislator's polytope size.

  • coord1DFirst dimension OC score, with all subsequent dimensions numbered similarly.

rollcalls

data frame, containing all data from the old perf21.dat file about bills. For a typical OCobject object run with an ORD file read using readKH, it will contain the following:

  • correctYeaPredicted Yeas and Actual Yeas.

  • wrongYeaPredicted Yeas and Actual Nays.

  • wrongNayPredicted Nays and Actual Yeas.

  • correctNayPredicted Nays and Actual Nays.

  • PREProportional Reduction In Error.

  • normvector1DFirst dimension of the unit normal vector, with all subsequent dimensions numbered similarly.

  • midpointsThe projection of the normal vector needed to get the midpoint.

dimensions

integer, number of dimensions estimated.

eigenvalues

A vector of roll call eigenvalues.

fits

A vector of length 2 with the classic measures of fit, containing the percent correct classification and the APRE.

Author(s)

Keith Poole [email protected]

Jeffrey Lewis [email protected]

James Lo [email protected]

Royce Carroll [email protected]

References

Keith Poole. 2000. 'Non-parametric Unfolding of Binary Choice Data.' Political Analysis, 8(3):211-237

Keith Poole. 2005. 'Spatial Models of Parliamentary Voting.' Cambridge: Cambridge University Press.

Keith Poole. https://legacy.voteview.com/

See Also

'plot.OCobject','summary.OCobject'.

Examples

#This data file is the same as reading file using:
    ## Not run: 
    sen90 <- readKH("https://voteview.com/static/data/out/votes/S090_votes.ord")
    
## End(Not run)
    #All ORD files can be found on voteview.com
    data(sen90)
    summary(sen90)

	#Small executable example
	sen90.1d <- oc(sen90,dims=1,polarity=c(7))

    #Output file identical to one produced by command below
    ## Not run: 
    sen90oc <- oc(sen90,dims=2,polarity=c(7,2))
	
## End(Not run)
    data(sen90oc)
    summary(sen90oc)
    plot(sen90oc)

Optimal Classification Cutting Line Angles Plot

Description

plot.angles reads an Optimal Classification object and plots a histogram of the angles of the cutlines for two dimensions. plot.angles does not work for one-dimensional OCobject objects.

Usage

## S3 method for class 'OCangles'
plot(x, main.title="Cutting Line Angles",
        x.title="Angle in Degrees", y.title="Count",
        dims=c(1,2),...)

Arguments

x

an OCobject output object.

main.title

string, coordinate plot title.

x.title

string, x-axis label.

y.title

string, y-axis label.

dims

vector of length 2, specifying the dimensions to be plotted.

...

other arguments to hist.

Value

A cutting line angle plot.

Author(s)

Keith Poole [email protected]

Jeffrey Lewis [email protected]

James Lo [email protected]

Royce Carroll [email protected]

See Also

'oc', 'plot.OCcoords', 'plot.OCskree', 'plot.OCcutlines', 'plot.OCobject'

Examples

#This data file is the same as that obtained using:
    ## Not run: 
    data(sen90)
    sen90oc <- oc(sen90,dims=2,polarity=c(7,2)) 
	
## End(Not run)

    data(sen90oc)
    summary(sen90oc)
    plot.OCangles(sen90oc)

Optimal Classification Coordinate Plot

Description

plot.coords reads an Optimal Classification object in 2 user-specified dimensions and plots the coordinates of each member, applying separate colors and shapes to each party by default. A unit circle is included to emphasize the constraints on the Optimal Classification coordinates, and options to select non-party attributes of legislators are included. For a 1D OCobject object, Optimal Classification ranks are plotted against themselves, so they appear on a straight line.

Usage

## S3 method for class 'OCcoords'
plot(x, main.title="OC Coordinates",
    d1.title="First Dimension", d2.title="Second Dimension", dims=c(1,2),
    plotBy="party", color=TRUE, shape=TRUE, cutline=NULL, Legend=TRUE,
    legend.x=0.8, legend.y=1,...)

Arguments

x

an OCobject output object.

main.title

string, coordinate plot title.

d1.title

string, x-axis label.

d2.title

string, y-axis label.

dims

vector of length 2, specifying the dimensions to be plotted.

plotBy

string, name of a variable in OCobject\$legislators. plot.coords will plot coordinates using this variable as a selector.

color

logical, marks different groups specified by plotBy using different colors if TRUE.

shape

logical, marks different groups specified by plotBy using different shapes if TRUE.

cutline

vector, selects roll calls by row number for which a cutting line is desired.

Legend

logical, include a generic legend.

legend.x

numeric, corresponds to the 'x' argument of legend().

legend.y

numeric, corresponds to the 'y' argument of legend().

...

other arguments to symbols.

Value

A coordinate plot.

Author(s)

Keith Poole [email protected]

Jeffrey Lewis [email protected]

James Lo [email protected]

Royce Carroll [email protected]

See Also

'oc', 'plot.OCskree', 'plot.OCangles', 'plot.OCcutlines', 'plot.OCobject'

Examples

#This data file is the same as that obtained using:
    ## Not run: 
    data(sen90)
    sen90oc <- oc(sen90,dims=2,polarity=c(7,2)) 
	
## End(Not run)

    data(sen90oc)
    summary(sen90oc)
    plot.OCcoords(sen90oc)

Optimal Classification Cutline Plot

Description

plot.cutlines reads an Optimal Classification object and plots the cutting line of a specified proportion of all votes along two user-specified dimensions. The default is to plot 50 cutting lines. This is also known as a Coombs mesh. A unit circle is included to emphasize the constraints on the Optimal Classification coordinates. Only cutlines that are constrained to have midpoints lying in a unit circle are included. plot.cutlines does not work for 1D OCobject objects.

Usage

## S3 method for class 'OCcutlines'
plot(x, main.title="Cutting Lines",
        d1.title="First Dimension", d2.title="Second Dimension",
        lines=50,dims=c(1,2),lwd=2,...)

Arguments

x

an OCobject output object.

main.title

string, coordinate plot title.

d1.title

string, x-axis label.

d2.title

string, y-axis label.

lines

numeric, number of non-constrained cutlines to be plotted. If this number exceeds to total number of cutlines, then all cutlines are plotted.

dims

numeric vector of length 2, specifying dimensions to be plotted.

lwd

numeric, line width.

...

other arguments to symbols.

Value

A Coombs mesh.

Author(s)

Keith Poole [email protected]

Jeffrey Lewis [email protected]

James Lo [email protected]

Royce Carroll [email protected]

See Also

'oc', 'plot.OCcoords', 'plot.OCskree', 'plot.OCangles', 'plot.OCobject'

Examples

#This data file is the same as that obtained using:
    ## Not run: 
    data(sen90)
    sen90oc <- oc(sen90,dims=2,polarity=c(7,2)) 
	
## End(Not run)

    data(sen90oc)
    summary(sen90oc)
    plot.OCcutlines(sen90oc)

Optimal Classification Summary Plot

Description

plot.OCobject reads an Optimal Classification object in two user-specified dimensions and plots the coordinates, cutting lines, a Coombs mesh, and a Skree plot. For one-dimensional OCobject objects, it plots a one-dimensional coordinate plot along with a Skree plot.

Usage

## S3 method for class 'OCobject'
plot(x, dims=c(1,2), ...)

Arguments

x

an OCobject output object.

dims

a vector of length 2, specifying the two dimensions to be plotted.

...

other arguments do nothing and are not passed to any plot functions.

Value

A summary plot of an OCobject object.

Author(s)

Keith Poole [email protected]

Jeffrey Lewis [email protected]

James Lo [email protected]

Royce Carroll [email protected]

See Also

'oc', 'plot.OCcoords', 'plot.OCskree', 'plot.OCangles', 'plot.OCcutlines'

Examples

#This data file is the same as that obtained using:
    ## Not run: 
    data(sen90)
    sen90oc <- oc(sen90,dims=2,polarity=c(7,2)) 
	
## End(Not run)

    data(sen90oc)
    summary(sen90oc)
    plot(sen90oc)

Optimal Classification Skree Plot

Description

plot.skree is the function that takes an Optimal Classification object and plots a Skree plot. Skree plots show the dimensionality of the voting by showing the sizes of the eigenvalues.

Usage

## S3 method for class 'OCskree'
plot(x, main.title="Skree Plot", x.title="Dimension",
        y.title="Eigenvalue",...)

Arguments

x

an OCobject output object.

main.title

string, Skree plot title.

x.title

string, x-axis label.

y.title

string, y-axis label.

...

other arguments to plot.

Value

A Skree plot, showing the first 20 eigenvalues.

Author(s)

Keith Poole [email protected]

Jeffrey Lewis [email protected]

James Lo [email protected]

Royce Carroll [email protected]

See Also

'oc', 'plot.OCcoords', 'plot.OCangles', 'plot.OCcutlines', 'plot.OCobject'

Examples

#This data file is the same as that obtained using:
    ## Not run: 
    data(sen90)
    sen90oc <- oc(sen90,dims=2,polarity=c(7,2)) 
	
## End(Not run)
    data(sen90oc)
    summary(sen90oc)
    plot.OCskree(sen90oc)

90th U.S. Senate Roll Call Vote Matrix

Description

This dataframe contains a matrix of votes cast by U.S. Senators in the 90th Congress. The data are formatted consistent with the rollcall object format in Simon Jackman's pscl package.

Usage

data(sen90)

Value

The dataframe contains roll call data for all Senators in the 90th Senate. The data is formatted as a rollcall object with the following elements.

votes

data frame, containing all data from the old nom31.dat file about legislators. For a typical W-NOMINATE object run with an ORD file read using readKH, it will contain the following:

  • state State name of legislator.

  • icpsrState ICPSR state code of legislator.

  • cd Congressional District number.

  • icpsrLegis ICPSR code of legislator.

  • party Party of legislator.

  • partyCode ICPSR party code of legislator.

codes

list of four vectors. yea shows the codes in votes that are yea votes, 'nay' shows nay codes, notInLegis shows absences, and missing shows the missing codes.

n

numeric, number of legislators

m

numeric, number of roll calls

legis.data

data frame, containing the following information on legislators:

  • state State name of legislator.

  • icpsrState ICPSR state code of legislator.

  • cd Congressional District number.

  • icpsrLegis ICPSR code of legislator.

  • party Party of legislator.

  • partyCode ICPSR party code of legislator.

vote.data

null, would otherwise be a data frame containing data on the votes.

desc

null, would otherwise be a string describing the data set.

source

string, describing where data set was read from.

Author(s)

Keith Poole [email protected]

Jeffrey Lewis [email protected]

James Lo [email protected]

Royce Carroll [email protected]

Source

Voteview team. 2017. 90th Senate Roll Call Vote Data. https://voteview.com/static/data/out/votes/S090_votes.ord.

See Also

'oc'.

Examples

#This data file is the same as reading file using:
    ## Not run: 
    sen90 <- readKH("https://voteview.com/static/data/out/votes/S090_votes.ord")
	
## End(Not run)
    data(sen90)
    summary(sen90)

    #Output file identical to one produced by command below
    ## Not run: 
    sen90oc <- oc(sen90,dims=2,polarity=c(7,2))
	
## End(Not run)
    data(sen90oc)
    summary(sen90oc)
    plot(sen90oc)

90th U.S. Senate Ideal Points via Optimal Classification

Description

This dataframe contains the estimated ideal points of the 90th U.S Senate using oc. Although it can easily be obtained from calling the example in oc, it is included here to facilitate illustration of the examples for the plot and summary functions.

Usage

data(sen90oc)

Value

An object of class OCobject, with elements as follows:

legislators

data frame, containing all data from the old perf25.dat file about legislators. For a typical ocObject run with an ORD file read using readKH, it will contain the following:

  • stateState name of legislator.

  • icpsrStateICPSR state code of legislator.

  • cdCongressional District number.

  • icpsrLegisICPSR code of legislator.

  • partyParty of legislator.

  • partyCodeICPSR party code of legislator.

  • rankRank ordering of legislator on the first dimension, from lowest to highest.

  • correctYeaPredicted Yeas and Actual Yeas.

  • wrongYeaPredicted Yeas and Actual Nays.

  • wrongNayPredicted Nays and Actual Yeas.

  • correctNayPredicted Nays and Actual Nays.

  • volumeMeasure of the legislator's polytope size.

  • coord1DFirst dimension OC score, with all subsequent dimensions numbered similarly.

rollcalls

data frame, containing all data from the old perf21.dat file about bills. For a typical OCobject object run with an ORD file read using readKH, it will contain the following:

  • correctYeaPredicted Yeas and Actual Yeas.

  • wrongYeaPredicted Yeas and Actual Nays.

  • wrongNayPredicted Nays and Actual Yeas.

  • correctNayPredicted Nays and Actual Nays.

  • PREProportional Reduction In Error.

  • normvector1DFirst dimension of the unit normal vector, with all subsequent dimensions numbered similarly.

  • midpointsThe projection of the normal vector needed to get the midpoint.

dimensions

integer, number of dimensions estimated.

eigenvalues

A vector of roll call eigenvalues.

fits

A vector of length 2 with the classic measures of fit, containing the percent correct classification and the APRE.

Author(s)

Keith Poole [email protected]

Jeffrey Lewis [email protected]

James Lo [email protected]

Royce Carroll [email protected]

Source

Voteview Team. 2017. 90th Senate Roll Call Vote Data. https://voteview.com/static/data/out/votes/S090_votes.ord.

See Also

'oc', 'plot.OCcoords', 'plot.OCskree', 'plot.OCangles', 'plot.OCcutlines', 'plot.OCobject'

Examples

#This data file is the same as that obtained using:
    ## Not run: 
    data(sen90)
    sen90oc <- oc(sen90,dims=2,polarity=c(7,2)) 
	
## End(Not run)

    data(sen90oc)
    summary(sen90oc)
    plot(sen90oc)

Optimal Classification Summary

Description

summary.OCobject reads an Optimal Classification object and prints a summary.

Usage

## S3 method for class 'OCobject'
summary(object,verbose=FALSE,...)

Arguments

object

an OCobject output object.

verbose

logical, includes all ideal points if TRUE, otherwise only returns the first 10 legislators.

...

other arguments do nothing and are not passed to any functions.

Value

A summary of a OCobject object.

Author(s)

Keith Poole [email protected]

Jeffrey Lewis [email protected]

James Lo [email protected]

Royce Carroll [email protected]

See Also

'oc', 'plot.OCcoords', 'plot.OCskree', 'plot.OCangles', 'plot.OCcutlines', 'plot.OCobject'

Examples

#This data file is the same as that obtained using:
    ## Not run: 
    data(sen90)
    sen90oc <- oc(sen90,dims=2,polarity=c(7,2)) 
	
## End(Not run)

    data(sen90oc)
    summary(sen90oc)
    plot(sen90oc)

United Nations Vote Data

Description

This data frame contains votes from the first three sessions of the United Nations. The same data can also be downloaded as a CSV file from https://legacy.voteview.com/. The object of this data set is to provide an example of how one might use the W-NOMINATE package on a set of roll call votes not already stored in ORD format.

Usage

data(UN)

Value

This data frame contains votes from the first three sessions of the United Nations. The first column are country names, while the second column indicates membership in the former Warsaw Pact (used as a 'party' variable). Yeas are coded 1, 2, and 3, nays are coded 4, 5, and 6, missing votes are coded 7, 8, and 9, and not being in the General Assembly is coded as a 0.

Author(s)

Keith Poole [email protected]

Jeffrey Lewis [email protected]

James Lo [email protected]

Royce Carroll [email protected]

Source

Keith Poole. 2005. UN Vote Data. https://legacy.voteview.com/.

See Also

'oc'.

Examples

#The same data set can be obtained from downloading the UN.csv
#file from legacy.voteview.com and reading it as follows:
## Not run: 
UN<-read.csv("UN.csv",header=FALSE,strip.white=TRUE)

## End(Not run)

data(UN)
UN<-as.matrix(UN)
UN[1:5,1:6]

UNnames<-UN[,1]
legData<-matrix(UN[,2],length(UN[,2]),1)
colnames(legData)<-"party"
UN<-UN[,-c(1,2)]

rc <- rollcall(UN, yea=c(1,2,3), nay=c(4,5,6),
missing=c(7,8,9),notInLegis=0, legis.names=UNnames,
legis.data=legData,
desc="UN Votes",
source="legacy.voteview.com")

# Not Run
## Not run: 
result<-oc(rc,polarity=1,dims=1)
plot(result)
summary(result)

## End(Not run)