plot_expected_ibbu_stanfit_categories: Plot expected bivariate (2D) categories from MV IBBU stanfit.

View source: R/visualize-NIW-IA-stanfit.R

plot_expected_ibbu_stanfit_categoriesR Documentation

Plot expected bivariate (2D) categories from MV IBBU stanfit.

Description

Plot bivariate Gaussian categories expected given the parameters inferred by incremental Bayesian belief- updating (IBBU). Specifically, the categories are derived by marginalizing over the uncertainty represented by the (post-warmup) MCMC samples. Two methods are available (specified by 'type'), which differ in their computational demands and speed.

Usage

plot_expected_ibbu_stanfit_categories(model, type, ...)

plot_expected_ibbu_stanfit_categories_contour(
  model,
  cues = get_cue_levels_from_stanfit(model),
  ...
)

plot_expected_ibbu_stanfit_categories_density(
  model,
  cues = get_cue_levels_from_stanfit(model),
  ...
)

plot_expected_ibbu_stanfit_categories_contour2D(
  model,
  categories = get_category_levels_from_stanfit(model),
  groups = get_group_levels_from_stanfit(model, include_prior = T),
  cues = get_cue_levels_from_stanfit(model),
  plot.test = T,
  plot.exposure = F,
  annotate_inferred_category_means = c("rug", "text"),
  untransform_cues = TRUE,
  levels = plogis(seq(-15, qlogis(0.95), length.out = 20)),
  category.colors = get_default_colors("category", categories)
)

plot_expected_ibbu_stanfit_categories_density1D(
  model,
  categories = get_category_levels_from_stanfit(model),
  groups = get_group_levels_from_stanfit(model, include_prior = T),
  cues = get_cue_levels_from_stanfit(model),
  ndraws = NULL,
  plot.test = T,
  plot.exposure = F,
  annotate_inferred_category_means = c("rug", "text"),
  untransform_cues = TRUE,
  category.colors = get_default_colors("category", categories),
  xlim = NULL,
  resolution = 101
)

plot_expected_ibbu_stanfit_categories_density2D(
  model,
  categories = get_category_levels_from_stanfit(model),
  groups = get_group_levels_from_stanfit(model, include_prior = T),
  cues = get_cue_levels_from_stanfit(model),
  ndraws = NULL,
  plot.test = T,
  plot.exposure = F,
  annotate_inferred_category_means = c("rug", "text"),
  untransform_cues = TRUE,
  category.colors = get_default_colors("category", categories),
  xlim = NULL,
  ylim = NULL,
  resolution = 25
)

Arguments

model

An mv-ibbu-stanfit object.

type

Either '"contour"' or '"density"', specifying the type of plot. Note that the contour plot is *much* faster. It simply gets the expected values of mu (based on the NIW parameter m) and Sigma (based on the NIW parameters S and nu) at each MCMC draw, and then averages over all MCMC draws. The plotted categories represent those means of the expected mu and Sigma. The density plot instead calculates the posterior predictive for each MCMC draw (i.e, the multivariate Student-T density based on the NIW parameters m, S, kappa, nu), and then averages those densities. Since this is done for *all* points defined by the data.grid this can be rather computationally expensive and slow.

categories, groups, cues

Character vector of categories, groups, and cues to be plotted. (default: all categories, groups, and cues in the model will be plotted)

plot.test, plot.exposure

Should the test and/or exposure stimuli be plotted? (default: 'TRUE' for 'plot.test', 'FALSE' for 'plot.exposure') The test items are plotted as black points. The exposure mean is plotted as point, and the .95 interval of cue distributions during exposure are plotted as dashed ellipse in the same color as the expected categories.

annotate_inferred_category_means

Character vector indicating whether the location and value of the mean be indicated through data rugs ('"rug"') and/or text labels ('"text"')? Set to NULL to ignore. (default: 'c("rug", "text")')

untransform_cues

Should m_0 and S_0 be transformed back into the original cue space? (default: 'TRUE')

levels

Used only if 'type' is '"contour"'. levels The cumulative probability levels that should be plotted (using 'geom_polygon()') around the mean. By default the most transparent ellipse still drawn corresponds to .95.

category.colors

Vector of colors of same length as categories.

ndraws

Number of draws from posterior to use for plot, or 'NULL' if all draws are to be returned. (default: 'NULL')

xlim, ylim

For density plots. Limits for the x- and y-axis.

resolution

For density plots. How many steps along x and y should be calculated? Note that computational complexity increases quadratically with resolution. (default: 25)

data.grid.xlim, data.grid.ylim, data.grid.resolution

Used only if 'type' is '"density"'. Limits for x- and y-axis as well as resolution of the data.grid, defining the range over which the posterior predictive (multivariate Student-T density) is calculated. Note that the number of densities to calculate is a *quadratic* function of 'data.grid.resolution'. The default for 'data.grid.resolution' is 10, corresponding to 100 densities to be calculated for each MCMC draw.

Details

Typically, the categories, groups, and cues are automatically added to the fit during the creation of the fit. If necessary, however, it is possible to use recover_types on the stanfit object to add or change these levels later.

Value

ggplot object.

See Also

TBD


hlplab/MVBeliefUpdatr documentation built on March 29, 2025, 10:42 p.m.