plot.bartcs {bartcs}R Documentation

Draw plot for bartcs object

Description

Two options are available: posterior inclusion probability (PIP) plot and trace plot.

Usage

## S3 method for class 'bartcs'
plot(x, method = NULL, parameter = NULL, ...)

Arguments

x

A bartcs object.

method

"pip" for posterior inclusion probability plot or "trace" for trace plot.

parameter

Parameter for traceplot.

...

Additional arguments for PIP plot. Check ?ggcharts::bar_chart for possible arguments.

Details

PIP plot

When a posterior sample is sampled during training, separate_bart() or single_bart() also counts which variables are included in the model and compute PIP for each variable. For bartcs object x, this is stored in x$var_count and x$var_prob respectively. plot(method = "pip") uses this information and draws plot using ggcharts::bar_chart().

Traceplot

Parameters are recorded for each MCMC iterations. Parameters include "ATE", "Y1", "Y0", "dir_alpha", and either "sigma2_out" from single_bart() or "sigma2_out1" and "sigma2_out0" from
separate_bart(). Vertical line indicates burn-in.

Value

A ggplot object of either PIP plot or trace plot.

Examples

data(ihdp, package = "bartcs")
x <- single_bart(
  Y               = ihdp$y_factual,
  trt             = ihdp$treatment,
  X               = ihdp[, 6:30],
  num_tree        = 10,
  num_chain       = 2,
  num_post_sample = 20,
  num_burn_in     = 10,
  verbose         = FALSE
)

# PIP plot
plot(x, method = "pip")
plot(x, method = "pip", top_n = 10)
plot(x, method = "pip", threshold = 0.5)
# Check `?ggcharts::bar_chart` for other possible arguments.

# trace plot
plot(x, method = "trace")
plot(x, method = "trace", "Y1")
plot(x, method = "trace", "dir_alpha")


[Package bartcs version 1.2.2 Index]