plot_rollcall: Plotting method for Individual Roll Calls from W-Nominate...

View source: R/asmcjr.r

plot_rollcallR Documentation

Plotting method for Individual Roll Calls from W-Nominate Model

Description

Produces a plot of the legislators and cutting line for an individual roll call vote for a wnominate object.

Usage

plot_rollcall(obj, data, gdat, rcnum, 
    shapeVar = NULL, dropNV=FALSE, 
    onlyErrors=FALSE, ptSize=4)

Arguments

obj

An object of class nomObject.

data

rollcall object used to estimate nomObject.

gdat

Minimally, a data frame with variables coord1D and coord2D, the first and second dimension coordinates from the nomObject. It could also include other variables, like one that will identify the shape of the points in the resulting ggplot. If NULL, the function will make the minimal dataframe for you. See the examples below, for how we made the gdat object.

rcnum

Number identifying the roll call to be plotted.

shapeVar

Name of the variable that identifies the shapes in the resulting ggplot.

dropNV

Whether or not those who didn't vote Yea or Nay.

onlyErrors

Should only those legislators who voted counter to their model predictions be plotted?

ptSize

Size of symbols passed to geom_point.

Value

A ggplot

Examples

# data(hr108)
# library(wnominate)
# result <- wnominate(hr108, ubeta=15, uweights=0.5, dims=2, minvotes=20,
#     lop=0.025, trials=1, polarity=c(1,5), verbose=FALSE)
# weight <-  result$weights[2]/result$weights[1] 
# weight
# wnom.dat <- data.frame(
#     coord1D = result$legislators$coord1D, 
#     coord2D = result$legislators$coord2D*weight,
#     party = result$legislators$partyCode,
#     state = result$legislators$icpsrState)

# wnom.dat$group <- NA
# wnom.dat$group[with(wnom.dat, which(party == 100 
#     & state %in% c(40:51, 53, 54)))] <- 1
# wnom.dat$group[with(wnom.dat, which(party == 100 
#     & state %in% c(1:39, 52, 55:82)))] <- 2
# wnom.dat$group[with(wnom.dat, which(party == 200))] <- 3
# wnom.dat$group[with(wnom.dat, which(party == 328))] <- 4
# wnom.dat$group <- factor(wnom.dat$group, levels=1:4, 
#     labels=c("Southern Dems", "Northern Dems", "Republicans", "Independents"))

# plot.rollcall(result, hr108, wnom.dat, 528, "group", TRUE) +                      
# theme_bw() + 
# theme(aspect.ratio=1) + 
# xlab("First Dimension") + ylab("Second Dimension") + ggtitle("The 108th House") 

davidaarmstrong/asmcjr documentation built on June 29, 2024, 12:07 p.m.