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 |
... |
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 |
sample_type |
Character string specifying the type of sample: "fitted", "predictive", or "estimand".
"fitted" and "predictive" are compatible with |
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 |
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 |
pip_cutoff |
Numeric threshold for the posterior inclusion probability (PIP) of model variables to include in the plot. |
Details
-
Sample and Plot Compatibility:
For
sample_type = "estimand"
, onlyplot_type = "hist"
or "trace" is allowed, as these are designed to visualize the posterior distribution or MCMC trajectory of individual parameters. Parameters likeintercept
,trt
, andsigma
are agnostic toeffect_type
as they do not interact with exposure.-
plot_type = "cred"
is designed for use withsample_type = "fitted"
or "predictive" and shows credible intervals for the outcome (y-axis) across biomarker values (x-axis) by covariate pattern.effect_type
controls whether the exposure effect or main effect is displayed.
-
Effect Types:
-
outcome
plots either the fitted or predictive values without exposure interaction, allowing for exposure (trt
) values to be specified. -
exposure_effect
plots the interaction of the exposure effect across different covariate patterns.
-
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")