plot_affect: Plot an individual's mean posterior predictions compared to...

View source: R/plot_affect.R

plot_affectR Documentation

Plot an individual's mean posterior predictions compared to their raw affect ratings

Description

plot_affect is capable of plotting either grouped or individual-level posterior predictions (vs. raw observations) for a defined list of posterior predictions and/or grouping.

Usage

plot_affect(
  data,
  plt_type = c("individual", "grouped", "weights"),
  adj_order = c("happy", "confident", "engaged"),
  nouns = c("Happiness", "Confidence", "Engagement"),
  id_no = NULL,
  r2_coords = c(0.9, 0.8),
  cred = c(0.95, 0.99),
  legend_pos = "right",
  pal = NULL,
  font = "",
  font_size = 11
)

Arguments

data

Either a list of outputs from get_affect_ppc, or parameters from make_par_df.

plt_type

Possible types are "grouped" or "individual" (for get_affect_ppc outputs) or "weights" (for make_par_df output).

adj_order

Same as fit_learning_model().

nouns

Formatted noun versions of the adjectives, in order.

id_no

If grouped == FALSE, a participant number to plot. If left as NULL, defaults to the individual with the median R^2 for each adjective.

r2_coords

If grouped == FALSE, coordinates to print the pseudo- R^2 value.

cred

Same as plot_glm, ignored unless plt_type == "weights".

legend_pos, pal, font, font_size

Same as plot_import.

Value

A single or list of ggplot object(s) depending on type.

Examples

## Not run: 
fit_affect <- fit_learning_model(
  example_data$nd,
  model = "2a",
  affect = TRUE,
  exp_part = "training",
  algorithm = "fullrank"
)

fit_dfs <- list()
for (adj in c("happy", "confident", "engaged")) {
  fits_dfs[[adj]] <- get_affect_ppc(
    fit_affect$draws, fit_affect$raw_df, adj = adj
  )
}

# Grouped plot
plot_affect(fit_dfs, plt_type = "grouped")

# Individual-level median posterior predictions
plot_affect(fit_dfs, plt_type = "individual", r2_coords = c(0.8, 0.97))

# Weight plot
pars <- make_par_df(fit_affect$raw, fit_affect$summary)
plot_affect(pars, plt_type = "weights"))

## End(Not run)


qdercon/pstpipeline documentation built on June 1, 2025, 1:11 p.m.