Learn R Programming

bayesics (version 2.0.2)

plot: Plots bayesics objects.

Description

Plots bayesics objects.

Usage

# S3 method for lm_b
plot(
  x,
  type,
  variable,
  exemplar_covariates,
  combine_pred_cred = TRUE,
  variable_seq_length = 30,
  return_as_list = FALSE,
  CI_level = 0.95,
  PI_level = 0.95,
  backtransformation = function(x) {
     x
 },
  ...
)

# S3 method for aov_b plot( x, type = c("diagnostics", "cred band", "pred band"), combine_pred_cred = TRUE, return_as_list = FALSE, CI_level = 0.95, PI_level = 0.95, ... )

# S3 method for lm_b_bma plot( x, type = c("diagnostics", "cred band", "pred band"), variable, exemplar_covariates, combine_pred_cred = TRUE, bayes_pvalues_quantiles = c(0.01, 1:19/20, 0.99), variable_seq_length = 30, return_as_list = FALSE, CI_level = 0.95, PI_level = 0.95, seed = 1, backtransformation = function(x) { x }, ... )

# S3 method for glm_b plot( x, type, variable, exemplar_covariates, combine_pred_cred = TRUE, variable_seq_length = 30, return_as_list = FALSE, CI_level = 0.95, PI_level = 0.95, seed = 1, ... )

# S3 method for np_glm_b plot( x, type, variable, exemplar_covariates, variable_seq_length = 30, return_as_list = FALSE, CI_level = 0.95, seed = 1, backtransformation = function(x) { x }, ... )

# S3 method for mediate_b plot(x, type, return_as_list = FALSE, ...)

# S3 method for survfit_b plot(x, n_draws = 10000, seed = 1, CI_level = 0.95, ...)

Value

If return_as_list=TRUE, a list of requested ggplots.

Arguments

x

A bayesics object

type

character. Select any of "diagnostics" ("dx" is also allowed), "pdp" (partial dependence plot), "cred band", and/or "pred band". NOTE: the credible and prediction bands only work for numeric variables. If plotting a mediate_b object, the valid values for type are "diagnostics" (or "dx"), "acme", or "ade".

variable

character. If type = "pdp" , which variable should be plotted?

exemplar_covariates

data.frame or tibble with exactly one row. Used to fix other covariates while varying the variable of interest for the plot.

combine_pred_cred

logical. If type includes both "cred band" and "pred band", should the credible band be superimposed on the prediction band or plotted separately?

variable_seq_length

integer. Number of points used to draw pdp.

return_as_list

logical. If TRUE, a list of ggplots will be returned, rather than a single plot produced by the patchwork package.

CI_level

Posterior probability covered by credible interval

PI_level

Posterior probability covered by prediction interval

backtransformation

function. If a transformation of the response variable was used, backtransformation should be the inverse of this transformation function. E.g., if you fit lm_b(log(y) ~ x), then set backtransformation=exp.

...

optional arguments.

bayes_pvalues_quantiles

ADD description!

seed

ADD description!

n_draws

integer. Number of posterior draws used for visualization of survival curves. Ignored if x is not a survfit_b object.

Examples

Run this code
# \donttest{
set.seed(2025)
N = 500
test_data <-
  data.frame(x1 = rnorm(N),
             x2 = rnorm(N),
             x3 = letters[1:5])
test_data$outcome <-
  rnorm(N,-1 + test_data$x1 + 2 * (test_data$x3 %in% c("d","e")) )
fit1 <-
  lm_b(outcome ~ x1 + x2 + x3,
       data = test_data)
plot(fit1)
# }


Run the code above in your browser using DataLab