bartcplot {bartCause}  R Documentation 
Plot methods for bartc
Description
Visual exploratory data analysis and model fitting diagnostics for causal inference models fit
using the bartc
function.
Usage
plot_sigma(x, main = "Traceplot sigma",
xlab = "iteration", ylab = "sigma",
lty = 1:x$n.chains,
...)
plot_est(x, main = paste("Traceplot", x$estimand),
xlab = "iteration", ylab = x$estimand,
lty = 1:x$n.chains, col = NULL,
...)
plot_indiv(x, main = "Histogram Individual Quantities",
type = c("icate", "mu.obs", "mu.cf", "mu.0",
"mu.1", "y.cf", "y.0", "y.1", "ite"),
xlab = "treatment effect",
breaks = 20,
...)
plot_support(x, main = "Common Support Scatterplot",
xvar = "tree.1", yvar = "tree.2",
sample = c("inferential", "all"),
xlab = NULL, ylab = NULL,
pch.trt = 21, bg.trt = "black",
pch.ctl = pch.trt, bg.ctl = NA,
pch.sup = pch.trt, bg.sup = NA, col.sup = "red", cex.sup = 1.5,
legend.x = "topleft", legend.y = NULL,
...)
Arguments
x 
Object of class 
main 
Character title of plot. 
xlab 
Character label of 
ylab 
Character label of 
lty 
For line plots ( 
col 
For line plots, use 
breaks 
Argument to 
type 
The individual quantity to be plotted. See 
xvar 
Variable for use on 
sample 
Return information for either the 
yvar 
Variable for use on the 
pch.trt 

bg.trt 

pch.ctl 

bg.ctl 

pch.sup 

bg.sup 

col.sup 

cex.sup 

legend.x 
x value passed to 
legend.y 
Optional y value passed to 
... 
Optional graphical parameters. 
Details
Produces various plots using objects fit by bartc
. plot_sigma
and plot_est
are traditional parameter trace plots that can be used to diagnose the convergence of the posterior
sampler. If the bartc
model is fit with n.chains
greater than one, by default each chain
will be plotted with its own line type.
plot_indiv
produces a simple histogram of the distribution of the estimates of the individual
effects, taken as the average of their posterior samples.
plot_support
is used to visualize the common support diagnostic in the form of a scatterplot.
Points that the diagnostic excludes are outlined in red. The contents of the x
and y
axes
are controlled by the xvar
and yvar
arguments respectively and can be of the form:

"tree.XX"
 Variable number"XX"
as selected by variable importance in predicting individual treatment effects using a tree fit byrpart
."XX"
must be a number not exceeding the number of continuous variables used to fit the response model. 
"pca.XX"
"XX"
th principal component axis. 
"css"
 The common support statistic. 
"y"
 Observed response variable. 
"y0"
 Predicted values for the response under the control as obtained byfitted
. 
"y1"
 Predicted values for the response under the treatmentfitted
. 
"indiv.diff"
 Individual treatment effect estimates, or\hat{y}(1)  \hat{y}(0)
. 
"p.score"
 Propensity score used to fit the response model (if applicable). 
"p.weights"
 Weights used when taking average of individual differences for response method"p.weight"
. predictor columns  Given by name or number.
supplied vector  Any vector of length equal to the number of observations.
Value
None, although plotting occurs as a sideeffect.
Author(s)
Vincent Dorie: vdorie@gmail.com.
See Also
Examples
# generate fake data using a simple linear model
n < 100L
beta.z < c(.75, 0.5, 0.25)
beta.y < c(.5, 1.0, 1.5)
sigma < 2
set.seed(725)
x < matrix(rnorm(3 * n), n, 3)
tau < rgamma(1L, 0.25 * 16 * rgamma(1L, 1 * 32, 32), 16)
p.score < pnorm(x %*% beta.z)
z < rbinom(n, 1, p.score)
mu.0 < x %*% beta.y
mu.1 < x %*% beta.y + tau
y < mu.0 * (1  z) + mu.1 * z + rnorm(n, 0, sigma)
# run with low parameters only for example
fit < bartc(y, z, x, n.samples = 100L, n.burn = 15L, n.chains = 2L,
n.threads = 1L,
commonSup.rule = "sd")
## plot specific functions
# sigma plot can be used to access convergence of chains
plot_sigma(fit)
# show points lacking common support
plot_support(fit, xvar = "tree.1", yvar = "css", legend.x = NULL)
# see example in ?"bartcgenerics" for rankordered individual effects plot