Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


Introduction to R Package Idealstan

Robert Kubinec October 26, 2018

Note: To report bugs with the package, please file an issue on the Github page. You are currently reading the README file, which largely follows the introductory vignette in the package. To install this package, type the command devtools::install_github('saudiwin/idealstan',local=F) at the R console prompt. To include the package vignettes in the package install, which can be accessed by the command vignette(package='idealstan), use instead the command devtools::install_github('saudiwin/idealstan',local=F,build_vignette=TRUE). To install the unstable development branch develop, use this command: devtools::install_github('saudiwin/idealstan',local=F,ref='develop').

If you use this package, please cite the following:

Kubinec, Robert. "Generalized Ideal Point Models for Time-Varying and Missing-Data Inference". Working Paper.

To install this package from source on Windows, please add the following to a file named Makevars.win, which should be located in the ~/.R directory (a directory named .R in the user home folder):

CXX11FLAGS=-O3
CXX14 = C:/Rtools/mingw_64/bin/g++ -m$(WIN) -std=c++1y
CXX14FLAGS=-O3

About the Package

This package implements IRT (item response theory) ideal point models, which are models designed for situations in which actors make strategic choices that correlate with a unidimensional scale, such as the left-right axis in American politics. Compared to traditional IRT, ideal point models examine the polarizing influence of a set of items on a set of persons, and has simlarities to models based on Euclidean latent spaces, such as multi-dimensional scaling. For more information, I refer you to my paper presented at StanCon 2018 and the R package vignettes that can be accessed on CRAN.

The goal of idealstan is to offer both standard ideal point models and additional models for missing data, time-varying ideal points and diverse responses, such as binary, ordinal, count, continuous and positive-continuous outcomes. In addition, idealstan uses the Stan estimation engine to offer full and variational Bayesian inference for all models so that every model is estimated with uncertainty. The package also exploits variational inference to automatically identify models instead of requiring users to pre-specify which persons or items in the data to constrain in advance.

The approach to handling missing data in this package is to model directly strategic censoring in observations. While this kind of missing data pattern can be found in many situations in which data is not missing at random, this particular version was developed to account for legislatures in which legislators (persons) are strategically absent for votes on bills (items). This approach to missing data can be usefully applied to many contexts in which a missing outcome is a function of the person's ideal point (i.e., people will tend to be present in the data when the item is far away or very close to their ideal point).

The package also includes ordinal ideal point models to handle situations in which a ranked outcome is polarizing, such as a legislator who can vote yes, no or to abstain. Because idealstan uses Bayesian inference, it can model any kind of ordinal data even if there aren't an even distribution of ordinal categories for each item.

The package also has extensive plotting functions via ggplot2 for model parameters, particularly the legislator (person) ideal points (ability parameters).

Copy Link

Version

Install

install.packages('idealstan')

Monthly Downloads

12

Version

0.7.2

License

GPL

Maintainer

Robert Kubinec

Last Published

July 10th, 2019

Functions in idealstan (0.7.2)

delaware

Rollcall vote data for Delaware State Legislature
id_plot_all_hist

Density plots of Posterior Parameters
id_estimate

Estimate an idealstan model
id_extract

Generic Method for Extracting Posterior Samples
id_make

Create data to run IRT model
id_plot_compare

Function to compare two fitted idealstan models by plotting ideal points. Assumes that underlying data is the same for both models.
id_extract,idealstan-method

Extract stan joint posterior distribution from idealstan object
id_plot,idealstan-method

derive_chain

Helper Function for `loo` calculation
id_plot

Generic Function for Plotting idealstan objects
id_plot_ppc

Plot Posterior Predictive Distribution for idealstan Objects
id_sim_rmse

RMSE function for calculating individual RMSE values compared to true simulation scores Returns a data frame with RMSE plus quantiles.
idealdata-class

Data and Identification for id_estimate
id_plot_rhats

Plotting Function to Display Rhat Distribution
launch_shinystan,idealstan-method

Function to Launch Shinystan with an idealstan Object
launch_shinystan

Generic Method to Use shinystan with idealstan
id_plot_legis_var

Plot Legislator/Person Over-time Variances
id_plot_ppc,idealstan-method

Plot Posterior Predictive Distribution for idealstan Objects
summary,idealstan-method

Posterior Summaries for fitted idealstan object
id_plot_legis

Plot Legislator/Person and Bill/Item Ideal Points
id_plot_cov

Marginal Effects Plot for Hierarchical Covariates
id_plot_legis_dyn

Function to plot dynamic ideal point models
id_plot_irf

Generate Impulse Response Functions for Covariates
idealstan-class

id_plot_sims

idealstan

idealstan package
id_sim_coverage

Function that computes how often the true value of the parameter is included within the 95/5 high posterior density interval
id_post_pred,idealstan-method

Posterior Prediction for idealstan objects
id_post_pred

Generic Method for Obtaining Posterior Predictive Distribution from Stan Objects
stan_trace,idealstan-method

Plot the MCMC posterior draws by chain
id_sim_gen

Simulate IRT ideal point data
id_sim_resid

Residual function for checking estimated samples compared to true simulation scores Returns a data frame with residuals plus quantiles.
release_questions

Function that provides additional check questions for package release
senate114

Rollcall vote data for 114th Senate
stan_trace

Plot the MCMC posterior draws by chain