Title: | Roll Call Analysis Software |
---|---|
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. |
Authors: | Keith Poole <[email protected]>, Jeffrey Lewis <[email protected]>, James Lo <[email protected]> and Royce Carroll <[email protected]> |
Maintainer: | Jeffrey B. Lewis <[email protected]> |
License: | GPL-2 |
Version: | 1.5 |
Built: | 2024-11-09 06:27:48 UTC |
Source: | CRAN |
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.
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')
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')
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. |
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. |
Keith Poole [email protected]
Jeffrey Lewis [email protected]
James Lo [email protected]
Royce Carroll [email protected]
dat<-generateTestData() result<-wnominate(dat,polarity=c(1,2)) summary(result) plot(result)
dat<-generateTestData() result<-wnominate(dat,polarity=c(1,2)) summary(result) plot(result)
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
.
nomprob(yea, nay, ideal, Beta, dimweight, normal=1)
nomprob(yea, nay, ideal, Beta, dimweight, normal=1)
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. |
An n x m matrix of probabilities giving the probability of yea for each of n legislators on each of m votes
Keith Poole [email protected]
Jeffrey Lewis [email protected]
James Lo [email protected]
Royce Carroll [email protected]
'generateTestData' and 'wnominate'.
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
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
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.
## S3 method for class 'angles' plot(x, main.title="Cutting Line Angles", x.title="Angle in Degrees", y.title="Count", dims=c(1,2), ...)
## S3 method for class 'angles' plot(x, main.title="Cutting Line Angles", x.title="Angle in Degrees", y.title="Count", dims=c(1,2), ...)
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 |
A cutting line angle plot.
Keith Poole [email protected]
Jeffrey Lewis [email protected]
James Lo [email protected]
Royce Carroll [email protected]
'wnominate', 'plot.coords', 'plot.scree', 'plot.cutlines', 'plot.nomObject'
#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)
#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)
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.
## 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, ...)
## 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, ...)
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 |
A coordinate plot.
Keith Poole [email protected]
Jeffrey Lewis [email protected]
James Lo [email protected]
Royce Carroll [email protected]
'wnominate', 'plot.scree', 'plot.cutlines', 'plot.angles', 'plot.nomObject'
#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)
#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)
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.
## 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, ...)
## 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, ...)
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 |
A Coombs mesh.
Keith Poole [email protected]
Jeffrey Lewis [email protected]
James Lo [email protected]
Royce Carroll [email protected]
'wnominate', 'plot.coords', 'plot.scree', 'plot.angles', 'plot.nomObject'
#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)
#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)
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.
## S3 method for class 'nomObject' plot(x, dims=c(1,2), ...)
## S3 method for class 'nomObject' plot(x, dims=c(1,2), ...)
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. |
A summary plot of a wnominate
object.
Keith Poole [email protected]
Jeffrey Lewis [email protected]
James Lo [email protected]
Royce Carroll [email protected]
'wnominate', 'plot.coords', 'plot.scree', 'plot.angles', 'plot.cutlines', 'plot.nomObject'
#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)
#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)
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.
## S3 method for class 'scree' plot(x, main.title="Scree Plot", x.title="Dimension", y.title="Eigenvalue", ...)
## S3 method for class 'scree' plot(x, main.title="Scree Plot", x.title="Dimension", y.title="Eigenvalue", ...)
x |
a |
main.title |
string, Skree plot title. |
x.title |
string, x-axis label. |
y.title |
string, y-axis label. |
... |
other arguments to |
A Scree plot, showing the first 20 eigenvalues.
Keith Poole [email protected]
Jeffrey Lewis [email protected]
James Lo [email protected]
Royce Carroll [email protected]
'wnominate', 'plot.coords', 'plot.cutlines', 'plot.angles', 'plot.nomObject'
#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)
#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)
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.
qnprob(yea,nay,ideal,Beta,dimweight,normal=1)
qnprob(yea,nay,ideal,Beta,dimweight,normal=1)
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. |
An n x m matrix of probabilities giving the probability of yea for each of n legislators on each of m votes
Keith Poole [email protected]
Jeffrey Lewis [email protected]
James Lo [email protected]
Royce Carroll [email protected]
'generateTestData' and 'wnominate'.
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
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
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.
data(sen90)
data(sen90)
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. |
Keith Poole [email protected]
Jeffrey Lewis [email protected]
James Lo [email protected]
Royce Carroll [email protected]
Keith Poole. 2005. 90th Senate Roll Call Vote Data. https://www.voteview.com/.
'wnominate'.
#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)
#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)
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.
data(sen90wnom)
data(sen90wnom)
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. |
Keith Poole [email protected]
Jeffrey Lewis [email protected]
James Lo [email protected]
Royce Carroll [email protected]
Keith Poole. 2005. 90th Senate Roll Call Vote Data. https://www.voteview.com/.
'wnominate'.
#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)
#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)
summary.nomObject
reads a W-NOMINATE object and prints a summary.
## S3 method for class 'nomObject' summary(object,verbose=FALSE, ...)
## S3 method for class 'nomObject' summary(object,verbose=FALSE, ...)
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. |
A summary of a wnominate
object. Correct classification, APRE, and GMP
are reported separately for each dimension.
Keith Poole [email protected]
Jeffrey Lewis [email protected]
James Lo [email protected]
Royce Carroll [email protected]
'wnominate', 'plot.coords', 'plot.scree', 'plot.angles', 'plot.cutlines', 'plot.nomObject'
#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)
#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)
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.
data(UN)
data(UN)
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.
Keith Poole [email protected]
Jeffrey Lewis [email protected]
James Lo [email protected]
Royce Carroll [email protected]
Keith Poole. 2005. UN Vote Data. https://legacy.voteview.com/.
'wnominate'.
#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)
#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)
wnominate
is the function that takes a rollcall
object and estimates Poole
and Rosenthal W-NOMINATE scores with them.
wnominate(rcObject, ubeta=15, uweights=0.5, dims=2, minvotes=20, lop=0.025,trials=3, polarity, verbose=FALSE)
wnominate(rcObject, ubeta=15, uweights=0.5, dims=2, minvotes=20, lop=0.025,trials=3, polarity, verbose=FALSE)
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. |
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. |
Keith Poole [email protected]
Jeffrey Lewis [email protected]
James Lo [email protected]
Royce Carroll [email protected]
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/
'generateTestData','plot.nomObject','summary.nomObject'.
#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)
#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)