Version: | 1.5 |
Date: | 2024-06-06 |
Title: | Roll Call Analysis Software |
Author: | Keith Poole <ktpoole@uga.edu>, Jeffrey Lewis <jblewis@ucla.edu>, James Lo <lojames@usc.edu> and Royce Carroll <rcarroll@rice.edu> |
Maintainer: | Jeffrey B. Lewis <jblewis@ucla.edu> |
Depends: | R (≥ 2.3.1), pscl (≥ 0.59), methods |
Description: | Estimates Poole and Rosenthal's (1985 <doi:10.2307/2111172>, 1991 <doi:10.2307/2111445>) W-NOMINATE scores from roll call votes supplied though a 'rollcall' object from the 'pscl' package. |
License: | GPL-2 |
Repository: | CRAN |
NeedsCompilation: | yes |
Packaged: | 2024-06-10 22:54:45 UTC; root |
Date/Publication: | 2024-06-11 03:50:02 UTC |
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 www.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 ktpoole@uga.edu
Jeffrey Lewis jblewis@ucla.edu
James Lo lojames@usc.edu
Royce Carroll rcarroll@rice.edu
Source
Keith Poole. 2005. UN Vote Data. https://legacy.voteview.com/.
See Also
'wnominate'.
Examples
#The same data set can be obtained from downloading the UN.csv
#file from www.voteview.com and reading it as follows:
#UN<-read.csv("C:/UN.csv",header=FALSE,strip.white=TRUE)
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="www.voteview.com")
# Not run
#result<-wnominate(rc,polarity=c(1,1))
#plot(result)
#summary(result)
Test Data Generator for W-NOMINATE
Description
generateTestData
is the function that generates a rollcall
object used to
test wnominate
. The description of the result below is copied from the
documentation of package pscl
, written by Simon Jackman.
Usage
generateTestData(legislators=20, rcVotes=100,
yea=matrix(runif(rcVotes,min=-0.2,max=0.7),nrow=rcVotes),
nay=matrix(runif(rcVotes,min=-0.7,max=0.2),nrow=rcVotes),
ideal=matrix(rnorm(legislators),nrow=legislators),
Beta=15, dimweight=0.5,normal=1, seed = NULL, utility='nominate')
Arguments
legislators |
integer, number of Legislators ('n'). |
rcVotes |
integer, number of roll calls ('m'). |
yea |
an m x d matrix of yea locations, where 'd' are the number of dimensions. |
nay |
an m x d matrix of no locations, where 'd' are the number of dimensions. |
ideal |
an n x d matrix of legislator ideal points. |
Beta |
scalar giving beta parameter from W-NOMINATE. |
dimweight |
d x 1 vector of dimension weights. |
normal |
integer, '1' generates data using normal probabilities, any other value generates data using logistic probabilities. |
seed |
a single value, interpreted as an integer, used to set the seed. If seed is NULL, current seed is used. |
utility |
String set to either “nominate” or “qn”. ‘nominate’ allows NOMINATE logit or probit utilities, while “qn” allows for quadratic normal utilities to be used when generating the roll call matrix. |
Value
An object of class rollcall
votes |
n x m vote matrix in 0/1/NA format. |
n |
integer, number of legislators. |
m |
integer, number of roll call votes. |
lopsided |
logical vector of length |
legis.data |
matrix, user-supplied data on legislators, containing data from an ORD file. Legislator names are rownames to this matrix. |
vote.data |
user-supplied data on rollcall votes, set to NULL. |
desc |
user-supplied description, set to NULL. |
Author(s)
Keith Poole ktpoole@uga.edu
Jeffrey Lewis jblewis@ucla.edu
James Lo lojames@usc.edu
Royce Carroll rcarroll@rice.edu
See Also
Examples
dat<-generateTestData()
result<-wnominate(dat,polarity=c(1,2))
summary(result)
plot(result)
NOMINATE Probability Matrix Generator
Description
nomprob
takes estimates from the W-NOMINATE model and returns a
matrix of yea choice probabilities. It is used to generate a test
rollcall
object using generateTestData
.
Usage
nomprob(yea, nay, ideal, Beta, dimweight, normal=1)
Arguments
For items below, m is the number of roll calls, n the number of legislators, and d the number of dimensions.
yea |
m x d matrix of yea locations. |
nay |
m x d matrix of no locations. |
ideal |
n x d matrix of legislator ideal points. |
Beta |
scalar giving beta parameter from W-NOMINATE. Usually set to 15. |
dimweight |
d x 1 vector of dimension weights. Usually set to 0.5. |
normal |
integer, '1' generates data using normal probabilities, any other value generates data using logistic probabilities. |
Value
An n x m matrix of probabilities giving the probability of yea for each of n legislators on each of m votes
Author(s)
Keith Poole ktpoole@uga.edu
Jeffrey Lewis jblewis@ucla.edu
James Lo lojames@usc.edu
Royce Carroll rcarroll@rice.edu
See Also
'generateTestData' and 'wnominate'.
Examples
yp <- matrix(rep(0,10),nrow=10)
np <- matrix(rep(0.1,10),nrow=10)
ideal <- matrix(rep(0,10),nrow=10)
nomprob(yp,np,ideal,15,0.5) #a matrix of yea probabilities
W-NOMINATE Cutting Line Angles Plot
Description
plot.angles
reads a W-NOMINATE object and plots a histogram of
the angles of the cutlines for two dimensions. plot.angles
does not
work for one-dimensional W-NOMINATE objects.
Usage
## S3 method for class 'angles'
plot(x, main.title="Cutting Line Angles",
x.title="Angle in Degrees", y.title="Count",
dims=c(1,2), ...)
Arguments
x |
a |
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 |
Value
A cutting line angle plot.
Author(s)
Keith Poole ktpoole@uga.edu
Jeffrey Lewis jblewis@ucla.edu
James Lo lojames@usc.edu
Royce Carroll rcarroll@rice.edu
See Also
'wnominate', 'plot.coords', 'plot.scree', 'plot.cutlines', 'plot.nomObject'
Examples
#This data file is the same as that obtained using:
#data(sen90)
#sen90wnom<-wnominate(sen90,polarity=c(2,5))
data(sen90wnom)
summary(sen90wnom)
plot.angles(sen90wnom)
plot(sen90wnom)
W-NOMINATE Coordinate Plot
Description
plot.coords
reads a W-NOMINATE 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 W-NOMINATE coordinates, and options to select non-party
attributes of legislators are included. For a 1D W-WNOMINATE object,
W-NOMINATE scores are plotted against their ranks.
Usage
## S3 method for class 'coords'
plot(x, main.title="W-NOMINATE 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 |
a |
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 |
color |
logical, marks different groups specified by |
shape |
logical, marks different groups specified by |
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 |
Value
A coordinate plot.
Author(s)
Keith Poole ktpoole@uga.edu
Jeffrey Lewis jblewis@ucla.edu
James Lo lojames@usc.edu
Royce Carroll rcarroll@rice.edu
See Also
'wnominate', 'plot.scree', 'plot.cutlines', 'plot.angles', 'plot.nomObject'
Examples
#This data file is the same as that obtained using:
#data(sen90)
#sen90wnom<-wnominate(sen90,polarity=c(2,5))
data(sen90wnom)
summary(sen90wnom)
plot.coords(sen90wnom)
plot(sen90wnom)
W-NOMINATE Cutline Plot
Description
plot.cutlines
reads a W-NOMINATE 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 W-NOMINATE
coordinates. Only cutlines that are constrained to have midpoints lying in a
unit circle are included. plot.cutlines
does not work for 1D W-NOMINATE objects.
Usage
## S3 method for class 'cutlines'
plot(x, main.title="Cutting Lines",
d1.title="First Dimension", d2.title="Second Dimension",
lines=50,dims=c(1,2),lwd=2, ...)
Arguments
x |
a |
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 |
Value
A Coombs mesh.
Author(s)
Keith Poole ktpoole@uga.edu
Jeffrey Lewis jblewis@ucla.edu
James Lo lojames@usc.edu
Royce Carroll rcarroll@rice.edu
See Also
'wnominate', 'plot.coords', 'plot.scree', 'plot.angles', 'plot.nomObject'
Examples
#This data file is the same as that obtained using:
#data(sen90)
#sen90wnom<-wnominate(sen90,polarity=c(2,5))
data(sen90wnom)
summary(sen90wnom)
plot.cutlines(sen90wnom)
plot(sen90wnom)
W-NOMINATE Summary Plot
Description
plot.nomObject
reads a W-NOMINATE object in two user-specified dimensions
and plots the coordinates, cutting lines, a Coombs mesh, and a Skree plot. For
1-dimensional W-NOMINATE objects, it plots the coordinates against the ranks
along with a Skree plot.
Usage
## S3 method for class 'nomObject'
plot(x, dims=c(1,2), ...)
Arguments
x |
a |
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 a wnominate
object.
Author(s)
Keith Poole ktpoole@uga.edu
Jeffrey Lewis jblewis@ucla.edu
James Lo lojames@usc.edu
Royce Carroll rcarroll@rice.edu
See Also
'wnominate', 'plot.coords', 'plot.scree', 'plot.angles', 'plot.cutlines', 'plot.nomObject'
Examples
#This data file is the same as that obtained using:
#data(sen90)
#sen90wnom<-wnominate(sen90,polarity=c(2,5))
data(sen90wnom)
summary(sen90wnom)
plot(sen90wnom)
W-NOMINATE Scree Plot
Description
plot.scree
is the function that takes a W-NOMINATE object and plots a Scree plot.
Scree plots show the dimensionality of the voting by showing the sizes of the eigenvalues.
Usage
## S3 method for class 'scree'
plot(x, main.title="Scree Plot", x.title="Dimension",
y.title="Eigenvalue", ...)
Arguments
x |
a |
main.title |
string, Skree plot title. |
x.title |
string, x-axis label. |
y.title |
string, y-axis label. |
... |
other arguments to |
Value
A Scree plot, showing the first 20 eigenvalues.
Author(s)
Keith Poole ktpoole@uga.edu
Jeffrey Lewis jblewis@ucla.edu
James Lo lojames@usc.edu
Royce Carroll rcarroll@rice.edu
See Also
'wnominate', 'plot.coords', 'plot.cutlines', 'plot.angles', 'plot.nomObject'
Examples
#This data file is the same as that obtained using:
#data(sen90)
#sen90wnom<-wnominate(sen90,polarity=c(2,5))
data(sen90wnom)
summary(sen90wnom)
plot.scree(sen90wnom)
plot(sen90wnom)
Qudaratic Normal Probability Matrix Generator
Description
qnprob
takes estimates from the Quadratic Normal model and returns a
matrix of yeah choice probabilities. It is used to generate a test
rollcall
object using generateTestData
. The function is set
up to take identical arguments to nomprob
, which explains why many
of the arguments do not do anything.
Usage
qnprob(yea,nay,ideal,Beta,dimweight,normal=1)
Arguments
For items below, m is the number of roll calls, n the number of legislators, and d the number of dimensions.
yea |
m x d matrix of yeah locations. |
nay |
m x d matrix of no locations. |
ideal |
n x d matrix of legislator ideal points. |
Beta |
Ignored. |
dimweight |
Ignored. |
normal |
integer, '1' generates data using normal probabilities, any other value generates data using logistic probabilities. |
Value
An n x m matrix of probabilities giving the probability of yea for each of n legislators on each of m votes
Author(s)
Keith Poole ktpoole@uga.edu
Jeffrey Lewis jblewis@ucla.edu
James Lo lojames@usc.edu
Royce Carroll rcarroll@rice.edu
See Also
'generateTestData' and 'wnominate'.
Examples
yp <- matrix(rep(0,10),nrow=10)
np <- matrix(rep(0.1,10),nrow=10)
ideal <- matrix(rep(0,10),nrow=10)
qnprob(yp,np,ideal,15,0.5) #a matrix of yea probabilities
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
|
codes |
list of four vectors. |
n |
numeric, number of legislators |
m |
numeric, number of roll calls |
legis.data |
data frame, containing the following information on legislators:
|
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 ktpoole@uga.edu
Jeffrey Lewis jblewis@ucla.edu
James Lo lojames@usc.edu
Royce Carroll rcarroll@rice.edu
Source
Keith Poole. 2005. 90th Senate Roll Call Vote Data. https://www.voteview.com/.
See Also
'wnominate'.
Examples
#This data file is the same as reading file using:
#sen90 <- readKH("ftp://voteview.com/sen90kh.ord")
#All ORD files can be found on www.voteview.com
data(sen90)
summary(sen90)
#sen90wnom <- wnominate(sen90,polarity=c(2,5))
#'sen90wnom' is the same nomObject as found in
data(sen90wnom)
summary(sen90wnom)
plot(sen90wnom)
90th U.S. Senate Ideal Points
Description
This dataframe contains the estimated ideal points of the 90th U.S Senate
using wnominate
. Although it can easily be obtained from calling
the example in wnominate
, it is included here to facilitate illustration
of the examples for the plot and summary functions.
Usage
data(sen90wnom)
Value
An object of class nomObject
, which in this documentation is also referred to
as a W-NOMINATE object.
legislators |
data frame, containing all data from the old
|
rollcalls |
data frame, containing all data from the old
|
dimensions |
integer, number of dimensions estimated. |
eigenvalues |
A vector of roll call eigenvalues. |
beta |
The beta value used in the final iteration. |
weights |
A vector of weights used in each iteration. |
fits |
A vector of length 3*dimensions with the classic measures of fit. In order, it contains the correct classifications for each dimension, the APREs for each dimension, and the overall GMPs for each dimension. |
Author(s)
Keith Poole ktpoole@uga.edu
Jeffrey Lewis jblewis@ucla.edu
James Lo lojames@usc.edu
Royce Carroll rcarroll@rice.edu
Source
Keith Poole. 2005. 90th Senate Roll Call Vote Data. https://www.voteview.com/.
See Also
'wnominate'.
Examples
#This data file is the same as reading file using:
#sen90 <- readKH("ftp://voteview.com/sen90kh.ord")
#All ORD files can be found on www.voteview.com
data(sen90)
summary(sen90)
#sen90wnom <- wnominate(sen90,polarity=c(2,5))
#'sen90wnom' is the same nomObject as found in
data(sen90wnom)
summary(sen90wnom)
plot(sen90wnom)
W-NOMINATE Summary
Description
summary.nomObject
reads a W-NOMINATE object and prints a summary.
Usage
## S3 method for class 'nomObject'
summary(object,verbose=FALSE, ...)
Arguments
object |
a |
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 wnominate
object. Correct classification, APRE, and GMP
are reported separately for each dimension.
Author(s)
Keith Poole ktpoole@uga.edu
Jeffrey Lewis jblewis@ucla.edu
James Lo lojames@usc.edu
Royce Carroll rcarroll@rice.edu
See Also
'wnominate', 'plot.coords', 'plot.scree', 'plot.angles', 'plot.cutlines', 'plot.nomObject'
Examples
#This data file is the same as that obtained using:
#data(sen90)
#sen90wnom<-wnominate(sen90,polarity=c(2,5))
data(sen90wnom)
summary(sen90wnom)
plot(sen90wnom)
W-NOMINATE Roll Call Scaling
Description
wnominate
is the function that takes a rollcall
object and estimates Poole
and Rosenthal W-NOMINATE scores with them.
Usage
wnominate(rcObject, ubeta=15, uweights=0.5, dims=2, minvotes=20,
lop=0.025,trials=3, polarity, verbose=FALSE)
Arguments
rcObject |
An object of class |
ubeta |
integer, beta parameter for NOMINATE. It is strongly recommended that you do not change the default. |
uweights |
integer, weight parameter for NOMINATE. It is strongly recommended that you do not change the default. |
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, |
trials |
integer, number of bootstrap trials for standard errors. Any number set below 4 here will not return any standard errors. Setting this number to be large will slow execution of W-NOMINATE considerably. |
polarity |
a vector specifying the legislator in the data set who is conservative on
each dimension. For example, |
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 nomObject
, which in this documentation is also referred to
as a W-NOMINATE object.
legislators |
data frame, containing all data from the old
|
rollcalls |
data frame, containing all data from the old
|
dimensions |
integer, number of dimensions estimated. |
eigenvalues |
A vector of roll call eigenvalues. |
beta |
The beta value used in the final iteration. |
weights |
A vector of weights used in each iteration. |
fits |
A vector of length 3*dimensions with the classic measures of fit. In order, it contains the correct classifications for each dimension, the APREs for each dimension, and the overall GMPs for each dimension. |
Author(s)
Keith Poole ktpoole@uga.edu
Jeffrey Lewis jblewis@ucla.edu
James Lo lojames@usc.edu
Royce Carroll rcarroll@rice.edu
References
Keith Poole and Howard Rosenthal. 1997. 'Congress: A Political-Economic History of Roll Call Voting.' New York: Oxford University Press.
Jeffrey Lewis. https://voteview.com/
Keith Poole, Jeffrey Lewis, James Lo, and Royce Carroll. 2011. ‘Scaling Roll Call Votes with WNOMINATE in R.’ Journal of Statistical Software, 42(14), 1-21. https://www.jstatsoft.org/v42/i14/
See Also
'generateTestData','plot.nomObject','summary.nomObject'.
Examples
#This data file is the same as reading file using:
#sen90 <- readKH("ftp://voteview.com/sen90kh.ord")
#All ORD files can be found on www.voteview.com
data(sen90)
summary(sen90)
#sen90wnom <- wnominate(sen90,polarity=c(2,5))
#'sen90wnom' is the same nomObject as found in
data(sen90wnom)
summary(sen90wnom)
plot(sen90wnom)