id_plot_all_hist: Density plots of Posterior Parameters

View source: R/Plot.R

id_plot_all_histR Documentation

Density plots of Posterior Parameters

Description

This function produces density plots of the different types of parameters in an idealstan model: item (bill) difficulty and discrimination parameters, and person (legislator) ideal points.

Usage

id_plot_all_hist(
  object,
  params = "person",
  param_labels = NULL,
  dens_type = "all",
  return_data = FALSE,
  func = median,
  ...
)

Arguments

object

A fitted idealstan object

params

Select the type of parameter from the model to plot. 'person' for person/legislator ideal points, 'miss_diff' and 'miss_discrim' for difficulty and discrimination parameters from the missing/inflated item/bill parameters, and 'obs_diff' and 'obs_discrim' for difficulty and discrimination parameters from the non-missing/non-inflated item/bill parameters.

param_labels

A vector of labels equal to the number of parameters. Primarily useful if return_data is TRUE.

dens_type

Can be 'all' for showing 90% HPD high, 10% HPD low and median posterior values. Or to show one of those posterior estimates at a time, use 'high' for 90% high HPD posterior estimate, 'low' for 10% low HPD posterior estimate, and 'function' for the whatever function is specificied in func (median by default).

return_data

Whether or not to return the plot as a ggplot2 object and the data together in a list instead of plotting.

func

The function to use if 'dens_type' is set to 'function'.

...

Other options passed on to the plotting function, currently ignored.

Value

A ggplot2 object showing density or histogram plots of the selected model parameters. If return_data=TRUE, a list with elements plot and data.

Examples


sim <- id_sim_gen()
est <- id_estimate(sim, model_type=1, fixtype='vb_full',
                   use_method="pathfinder", nchains=2, ncores=2)
# plot posterior distribution of person ideal points
id_plot_all_hist(est, params='person')
# plot item discrimination parameters
id_plot_all_hist(est, params='obs_discrim')


idealstan documentation built on May 13, 2026, 1:08 a.m.