# idealstan v0.5.1

Monthly downloads

## Generalized IRT Ideal Point Models with 'Stan'

Offers item-response theory (IRT) ideal-point estimation for binary, ordinal, counts and continuous responses with time-varying and missing-data inference. Full and approximate Bayesian sampling with 'Stan' (www.mc-stan.org).

## Readme

# 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.

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).

## Functions in idealstan

Name | Description | |

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_plot_cov | Display Coefficient Plot of Hierarchical Covariates | |

id_plot_sims | This function plots the results from a simulation generated by id_sim_gen. | |

id_post_pred,idealstan-method | Posterior Prediction for idealstan objects | |

launch_shinystan,idealstan-method | Function to Launch Shinystan with an idealstan Object | |

launch_shinystan | Generic Method to Use shinystan with idealstan | |

id_make | Create data to run IRT model | |

id_plot,idealstan-method | Plot Results of id_estimate | |

id_plot_rhats | Plotting Function to Display Rhat Distribution | |

id_plot_ppc | Plot Posterior Predictive Distribution for idealstan Objects | |

idealstan | idealstan package | |

idealstan-class | Results of id_estimate function | |

summary,idealstan-method | Posterior Summaries for fitted idealstan object | |

id_extract,idealstan-method | Extract stan joint posterior distribution from idealstan object | |

id_extract | Generic Method for Extracting Posterior Samples | |

id_post_pred | Generic Method for Obtaining Posterior Predictive Distribution from Stan Objects | |

derive_chain | Helper Function for `loo` calculation | |

id_plot | Generic Function for Plotting idealstan objects | |

id_estimate | Estimate an idealstan model | |

id_plot_all_hist | Density plots of Posterior Parameters | |

id_plot_legis_var | Plot Legislator/Person Over-time Variances | |

id_plot_legis | Plot Legislator/Person and Bill/Item Ideal Points | |

id_plot_ppc,idealstan-method | Plot Posterior Predictive Distribution for idealstan Objects | |

id_sim_coverage | Function that computes how often the true value of the parameter is included within the 95/5 high posterior density interval | |

release_questions | Function that provides additional check questions for package release | |

id_plot_legis_dyn | Function to plot dynamic ideal point models | |

id_sim_rmse | RMSE function for calculating individual RMSE values compared to true simulation scores Returns a data frame with RMSE plus quantiles. | |

id_sim_gen | Simulate IRT ideal point data | |

idealdata-class | Data and Identification for id_estimate | |

senate114 | Rollcall vote data for 114th Senate | |

stan_trace,idealstan-method | Plot the MCMC posterior draws by chain | |

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

stan_trace | Plot the MCMC posterior draws by chain | |

No Results! |

## Vignettes of idealstan

Name | ||

How_to_Evaluate_Models.Rmd | ||

How_to_Evaluate_Models.html.asis | ||

Package_Introduction.Rmd | ||

Package_Introduction.html.asis | ||

Time_Series.Rmd | ||

Time_Series.html.asis | ||

No Results! |

## Last month downloads

## Details

Type | Package |

Date | 2018-11-26 |

BugReports | https://github.com/saudiwin/idealstan/issues |

License | GPL |

LinkingTo | StanHeaders (>= 2.18.0), rstan (>= 2.18.2), BH (>= 1.66), Rcpp (>= 0.12.7), RcppEigen (>= 0.3.2.9.0) |

Encoding | UTF-8 |

LazyData | true |

NeedsCompilation | yes |

SystemRequirements | GNU make |

VignetteBuilder | R.rsp |

RoxygenNote | 6.1.0 |

Packaged | 2018-12-06 21:26:50 UTC; rkubinec |

Repository | CRAN |

Date/Publication | 2018-12-06 21:50:04 UTC |

imports | bayesplot , dplyr , forcats , gghighlight , ggplot2 , ggrepel , lazyeval , rlang , rstan (>= 2.18.2) , rstantools (>= 1.5.1) , shinystan , stringr , tidyr |

linkingto | BH (>= 1.66) , RcppEigen (>= 0.3.2.9.0) , StanHeaders (>= 2.18.0) |

suggests | loo , lubridate , pscl , R.rsp |

depends | methods , R (>= 3.4.0) , Rcpp (>= 0.12.18) |

Contributors | Ben Goodrich, Jonah Gabry, Trustees of Columbia University |

#### Include our badge in your README

```
[![Rdoc](http://www.rdocumentation.org/badges/version/idealstan)](http://www.rdocumentation.org/packages/idealstan)
```