plot_ibbu_stanfit_test_categorization: Plot prior and posterior categorization of test tokens.

plot_ibbu_stanfit_test_categorizationR Documentation

Plot prior and posterior categorization of test tokens.

Description

Categorize test tokens by prior and/or posterior beliefs, and plot the resulting categorization function along a one-dimensional continuum (regardless of the dimensionality of the cue space in which categorization takes place). This provides the type of categorization plot typical for, for example, perceptual recalibration or phonetic tuning studies.

Usage

plot_ibbu_stanfit_test_categorization(
  model,
  data.test = NULL,
  groups = get_group_levels_from_stanfit(model, include_prior = TRUE),
  summarize = T,
  ndraws = NULL,
  confidence.intervals = c(0.66, 0.95),
  target_category = 1,
  panel.group = if (plot_in_cue_space) TRUE else FALSE,
  group.colors = get_default_colors("group", groups),
  group.linetypes = get_default_linetypes("group", groups),
  category.colors = get_default_colors("category", categories),
  all_test_locations = TRUE,
  plot_in_cue_space = FALSE,
  untransform_cues = TRUE,
  sort_by = if (plot_in_cue_space) NULL else "prior"
)

Arguments

model

NIW_ideal_adaptor_stanfit object.

data.test

Optionally, a tibble or data.frame with test data. If 'NULL' the input will be extracted from fit. (default: 'NULL').

groups

Character vector of groups to be plotted. Typically, the levels of these factors 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. (default: all categories/groups will be plotted)

summarize

Should one categorization function (optionally with CIs) be plotted ('TRUE') or should separate unique categorization function be plotted for each MCMC draw ('FALSE')? (default: 'TRUE')

ndraws

Number of draws to plot (or use to calculate the CIs), or 'NULL' if all draws are to be returned. (default: 'NULL')

confidence.intervals

The two confidence intervals that should be plotted (using 'geom_ribbon') around the mean. (default: 'c(.66, .95)')

target_category

The index of the category for which categorization should be shown. (default: '1')

panel.group

Should the groups be plotted in separate panels? (default: 'FALSE')

group.colors, group.linetypes

Vector of colors and linetypes of same length as 'groups' or 'NULL' to use defaults.

category.colors

Vector of colors and linetypes of same length as 'categories' or 'NULL' to use defaults. Only relevant when 'plot_in_cue_space = TRUE'.

all_test_locations

Should predictions be shown for all combinations of test locations and group, or should only combinations be shown that actually occurred in the data? (default: 'FALSE')

plot_in_cue_space

Should predictions be plotted in the cue space? If not, test tokens are treated as factors and sorted along the x-axis based on 'sort_by'. (default: 'TRUE')

untransform_cues

Should the cues be untransformed before plotting? This should only have visual consequences if 'plot_in_cue_space = T'. (default: 'TRUE')

sort_by

Which group, if any, should the x-axis be sorted by (in increasing order of posterior probability from left to right). Set to 0 for sorting by prior (default). Set to 'NULL' if no sorting is desired. (default: '"prior"')

Details

Tokens are sorted based on the increasing probability of a target_category response for the condition (group, e.g., prior or a specific exposure group) specified in sort_by. By default both the mean categorization and confidence intervals are plotted. If 'summarize=TRUE', the function marginalizes over all posterior samples. The number of samples is determined by ndraws. If ndraws is NULL, all samples are used. Otherwise ndraws random samples will be used. If 'summarize=FALSE', separate categorization plots for all ndraws individual samples will be plotted in separate panels.

Value

ggplot object.

See Also

TBD


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