plot_raincloud: Raincloud plots

View source: R/plot_raincloud.R

plot_raincloudR Documentation

Raincloud plots

Description

plot_raincloud plots simple "raincloud" plots of posterior densities, most likely for model parameters (by group).

Usage

plot_raincloud(
  summary_df,
  raw_df,
  pars_of_interest = NULL,
  type = "parameter",
  test = FALSE,
  by = NULL,
  recode_na = 0,
  par_nms = type,
  par_vals = "posterior_mean",
  par_lvls = NULL,
  par_labs = NULL,
  afct_filt = NULL,
  afct_col = NULL,
  combine_with = NULL,
  legend_title = by,
  legend_labels = NULL,
  legend_pos = "right",
  factor_scores = NULL,
  flip = TRUE,
  cred = c(0.95, 0.99),
  dist_nudge = 0.1,
  box_width = 0.1,
  scatter = c(width = 0.15, nudge = 0.225),
  pal = NULL,
  font_size = 11,
  font = "",
  ...
)

Arguments

summary_df

List of cmdstanr::summary() outputs for the fit(s) of interest.

raw_df

List of raw data inputs to the above fits (in the same order). Used to correctly link subject IDs to independent variables.

pars_of_interest

Vector of parameters to plot, for example if we want to only plot a specific parameter by a certain demographic variable.

type

Type of plot to return - either separate plots for each parameter, or each transdiagnostic symptom factor.

test

Boolean indicating whether summaries are from the test phase.

by

Separately plot distributions by a certain demographic variable?

recode_na

Value to recode NAs in the by variable to.

par_nms

The name of the column that contains the discrete axis labels (i.e., the parameter or factor score names).

par_vals

The name of the column that contains the continuous values to plot (i.e., the parameter values or factor scores).

par_lvls

The order in which to plot the parameters or factors.

par_labs

Modify the labels of the parameters or factors - must be in the same order as par_lvls.

afct_filt

Affect adjective to filter on, if affect = TRUE.

afct_col

Column containing the affect types.

combine_with

A column to combine with the par_nms variable, if this is further split by another variable.

legend_title, legend_labels, legend_pos

Controls to name and label the items in the legend (as these may be formatted poorly if by != NULL), plus to set its position.

factor_scores

data.frame with the derived transdiagnostic factor scores, required if type = "factor".

flip

Boolean indicating if the axes should be flipped.

cred

Vector, length 2, which defines the % HDI covered by the boxplot boxes and lines respectively.

dist_nudge

Controls the position of the distribution plots in the x-direction.

box_width

Control the total width of the boxplot(s).

scatter

Either a named vector of scatterplot width, and nudge. Use NULL to omit the scatterplots from the plot entirely.

pal, font_size, font

Same as plot_import().

...

Additional arguments such as alpha_par_nms to alter axis titles or control the moment used in quantile_hdi().

Value

A ggplot.

Examples

## Not run: 
data(example_data)

fit_nd <- fit_learning_model(
  example_data$nd,
  model = "2a",
  vb = FALSE,
  exp_part = "training"
)
fit_dis <- fit_learning_model(
  example_data$dis,
  model = "2a",
  vb = FALSE,
  exp_part = "training"
)

plot_raincloud(
  summary_df = list(fit_nd$summary, fit_dis$summary),
  raw_df = list(fit_nd$raw_df, fit_dis$raw_df),
  by = "distanced",
  flip = FALSE
)

## End(Not run)


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