plot.rjMCMC {fkbma}R Documentation

Plotting function for rjMCMC results

Description

This function generates plots for model results from rjMCMC based on specified sample type, effect type, and plot type. The function is flexible for various combinations of sample_type, effect_type, and plot_type, as outlined below.

Usage

## S3 method for class 'rjMCMC'
plot(
  x,
  ...,
  variables = NULL,
  sample_type = "fitted",
  effect_type = "exposure_effect",
  plot_type = "cred",
  level = 0.95,
  aux_vars = list(),
  facet_by = NULL,
  pip_cutoff = 0.1
)

Arguments

x

A fitted model object from rjMCMC.

...

Additional arguments to be passed to other methods or functions.

variables

A vector of variable names to include in the plot. Automatically set to continuous variables if NULL.

sample_type

Character string specifying the type of sample: "fitted", "predictive", or "estimand". "fitted" and "predictive" are compatible with plot_type = "cred". "estimand" is compatible with plot_type = "hist" or "trace" (only used for individual parameter trajectories).

effect_type

Character string indicating the effect type: "exposure_effect" or "outcome". For "exposure_effect", the function plots the fitted or predictive effect of exposure; for "outcome", it plots outcome values without interaction with exposure.

plot_type

Character string specifying the plot type: "cred" for credible interval plots, or "hist"/"trace" for histogram or trace plots of individual parameters (only for sample_type = "estimand").

level

Numeric value for the credible interval level (default is 0.95).

aux_vars

A list of auxiliary variables and their fixed values. Each element name must match a model variable.

facet_by

A vector of variable names to facet by in the plot. Automatically set to binary model variables if NULL.

pip_cutoff

Numeric threshold for the posterior inclusion probability (PIP) of model variables to include in the plot.

Details

Value

A ggplot2 object or a grid of plots.

Examples


# Example dataset
data("simulated_data")

candsplinevars <- c("X_1")
candbinaryvars <- paste0("Z_", 1:5)
candinter <- c(candsplinevars, candbinaryvars)

results <- rjMCMC(simulated_data, candsplinevars, candbinaryvars, candinter,
                  outcome = "Y", factor_var = "trt")
plot(results, sample_type = "fitted", effect_type = "exposure_effect", plot_type = "cred")
plot(results, sample_type = "estimand", plot_type = "hist")


[Package fkbma version 0.2.0 Index]