Skip to main content

Plot Item Discrimination or Difficulty Parameters

Description

This function plots item-level parameters (discrimination or difficulty) from a fitted idealstan object. It can display both observed (non-inflated) and missing (inflated) item parameters.

Usage

id_plot_items(
  object,
  param_type = "discrimination",
  item_type = "both",
  include = NULL,
  high_limit = 0.95,
  low_limit = 0.05,
  text_size_label = 2,
  point_size = 1,
  item_labels = TRUE,
  order_by = "median",
  return_data = FALSE,
  show_true = FALSE,
  use_chain = NULL,
  ...
)

Arguments

object A fitted idealstan object
param_type Which parameter to plot: “discrimination” (default) or “difficulty”
item_type Which item parameters to show: “both” (default), “observed”, or “missing”. “observed” shows the non-inflated parameters (gamma/beta), “missing” shows the inflated/absence parameters (nu/omega).
include A character vector of item IDs to include in the plot (all others excluded). If NULL (default), all items are shown.
high_limit The quantile (number between 0 and 1) for the high end of posterior uncertainty to show in plot. Default is 0.95.
low_limit The quantile (number between 0 and 1) for the low end of posterior uncertainty to show in plot. Default is 0.05.
text_size_label The size of text labels for item names. Default is 2.
point_size The size of points in the plot. Default is 1.
item_labels If TRUE (default), show item name labels on the plot.
order_by How to order items: “median” (default) orders by posterior median, “name” orders alphabetically by item name, “uncertainty” orders by width of posterior interval.
return_data If TRUE, return the data used for plotting along with the plot as a list. Default is FALSE.
show_true If the model was fitted on simulated data, show the true parameter values. Default is FALSE.
use_chain Which MCMC chains to use. Default is NULL (use all chains).
… Other arguments (currently ignored)

Value

A ggplot2 object, or if return_data=TRUE, a list with elements plot and data.

Examples

library("idealstan")




# 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',
time_id='date')

fitted_model <- 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.3 seconds.
Pareto k value (10) 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  15.8 seconds.
# After fitting a model:
# Plot discrimination parameters for all items
id_plot_items(fitted_model)

# Plot only difficulty parameters
id_plot_items(fitted_model, param_type = "difficulty")

# Plot only observed (non-inflated) discrimination
id_plot_items(fitted_model, item_type = "observed")

# Plot specific items only
id_plot_items(fitted_model, include = c("224", "368", "391"))