plotHistTrace {fkbma}R Documentation

Generate Histogram and Trace Plots for MCMC Samples

Description

This internal function creates histogram or trace plots for MCMC samples from an rjMCMC model, displaying the posterior distributions or sampling trajectories of specified variables.

Usage

plotHistTrace(
  results,
  variables = NULL,
  sample_type = "fitted",
  effect_type = "exposure_effect",
  plot_type = "cred",
  aux_vars = list(),
  facet_by = NULL
)

Arguments

results

A fitted model object from rjMCMC.

variables

A vector of variable names to include in the plot, representing the estimand or covariates of interest.

sample_type

Character string specifying the sample type: "estimand", "fitted", or "predictive". When set to "estimand", the function plots individual parameters from the posterior. For "fitted" or "predictive", it uses posterior samples for one individual’s fitted or predictive values.

plot_type

Character string specifying the plot type: "hist" for histogram or "trace" for trace plots. "hist" shows the distribution of parameter values, while "trace" displays MCMC sampling trajectories.

aux_vars

A list of auxiliary variables and their values. Used to generate data for fitted or predictive values. Each element name should correspond to a model variable.

facet_by

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

Details

Value

A ggplot2 object displaying histograms or trace plots of the MCMC samples.

Note

This is an internal function not intended for direct use by package users.


[Package fkbma version 0.2.0 Index]