Skip to main content

Plot Legislator/Person and Bill/Item Ideal Points

Description

This function can be used on a fitted idealstan object to plot the relative positions and uncertainties of legislator/persons and bills/items.

Usage

id_plot_persons(
  object,
  return_data = FALSE,
  include = NULL,
  high_limit = 0.95,
  low_limit = 0.05,
  item_plot = NULL,
  item_plot_type = "non-inflated",
  text_size_label = 2,
  text_size_group = 2.5,
  point_size = 1,
  hjust_length = -0.7,
  person_labels = TRUE,
  group_labels = FALSE,
  person_ci_alpha = 0.2,
  show_true = FALSE,
  group_color = TRUE,
  hpd_limit = NULL,
  sample_persons = NULL,
  dim = 1,
  ...
)

Arguments

object A fitted idealstan object or a named list of idealstan objects to compare across models
return_data If true, the calculated legislator/bill data is returned along with the plot in a list
include Specify a list of person/legislator IDs to include in the plot (all others excluded)
high_limit The quantile (number between 0 and 1) for the high end of posterior uncertainty to show in plot
low_limit The quantile (number between 0 and 1) for the low end of posterior uncertainty to show in plot
item_plot The IDs (character vector) of the bill/item midpoints to overlay on the plot
item_plot_type Whether to show the ‘non-inflated’ item/bill midpoints, the ‘inflated’ item/bill midpoints, or produce plots for ‘both’ kinds of models. Defaults to ‘non-inflated’ and will only display an item/bill midpoint if one has been specified in item_plot.
text_size_label ggplot2 text size for legislator labels
text_size_group ggplot2 text size for group text used for points
point_size If person_labels and group_labels are set to FALSE, controls the size of the points plotted.
hjust_length horizontal adjustment of the legislator labels
person_labels if TRUE, use the person_id column to plot labels for the person (legislator) ideal points
group_labels if TRUE, use the group column to plot text markers for the group (parties) from the person/legislator data
person_ci_alpha The transparency level of the dot plot and confidence bars for the person ideal points
show_true Whether to show the true values of the legislators (if model has been simulated)
group_color If TRUE, give each group/bloc a different color
hpd_limit The greatest absolute difference in high-posterior density interval shown for any point. Useful for excluding imprecisely estimated persons/legislators from the plot. Default is NULL if you don’t want to exclude any.
sample_persons If you don’t want to use the full number of persons/legislators from the model, enter a proportion (between 0 and 1) to select only a fraction of the persons/legislators.
dim For models with more than one dimension (num_dim in id_estimate()), which dimension to plot. Default is 1.
… Other options passed on to plotting function, currently ignored

Details

This plot shows the distribution of ideal points for the legislators/persons in the model. It will plot them as a vertical dot plot with associated high-density posterior interval (can be changed with high_limit and low_limit options). In addition, if item/bill IDs as a character vector is passed to the item_plot option, then an item/bill midpoint will be overlain on the ideal point plot, showing the point at which legislators/persons are indifferent to voting/answering on the bill/item. Note that because this is an ideal point model, it is not possible to tell from the midpoint itself which side will be voting which way. For that reason, the legislators/persons are colored by their votes/scores to make it clear.

To compare across multiple idealstan models, pass a named list list(model1=model1,model2=model2,etc) to the object option. Note that these comparisons will done by individual persons/groups, so if there are a lot of persons/groups, consider using the include option to only compare a specific set of persons/groups.

Value

A ggplot2 object showing person/legislator ideal points as a dot plot with posterior intervals. If return_data=TRUE, a list with elements plot and data.

Examples

library("idealstan")





# First create data and run a model

# absences become missing values, and the votes 0 (No) and 1 (Yes)
senate114$cast_code <- ifelse(senate114$cast_code=="Absent", NA,
                              as.integer(senate114$cast_code) - 1L)

to_idealstan <-   id_make(score_data = senate114,
outcome_disc = 'cast_code',
person_id = 'bioname',
item_id = 'rollnumber',
group_id= 'party_code',
time_id='date')

sen_est <- id_estimate(to_idealstan,
model_type = 2,
use_method = "pathfinder",
fixtype='vb_partial',
restrict_ind_high = "BARRASSO, John A.",
restrict_ind_low = "WARREN, Elizabeth")
Finished in  6.7 seconds.
Pareto k value (11) is greater than 0.7. Importance resampling was not able to improve the approximation, which may indicate that the approximation itself is poor. 
Finished in  20.0 seconds.
# After running the model, we can plot 
# the results of the person/legislator ideal points

id_plot_persons(sen_est)