% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plots.R
\name{plot.CausalShrinkageForest}
\alias{plot.CausalShrinkageForest}
\title{Plot diagnostics for a CausalShrinkageForest model}
\usage{
\method{plot}{CausalShrinkageForest}(
  x,
  type = c("trace", "density", "ate", "cate", "vi"),
  forest = c("both", "control", "treat"),
  n_vi = 10,
  bayesian_bootstrap = TRUE,
  ...
)
}
\arguments{
\item{x}{A \code{CausalShrinkageForest} object.}

\item{type}{Character; one of:
\describe{
\item{\code{"trace"}}{Sigma traceplot (chain mixing).}
\item{\code{"density"}}{Overlaid posterior density of sigma per chain.}
\item{\code{"ate"}}{Posterior density of the average treatment effect
(ATE) with 95 percent credible region. Requires
\code{store_posterior_sample = TRUE}.}
\item{\code{"cate"}}{Point estimates and 95 percent credible intervals
for the CATE of each training observation, sorted by posterior mean.
Requires \code{store_posterior_sample = TRUE}.}
\item{\code{"vi"}}{Posterior credible intervals for variable inclusion
probabilities (Dirichlet prior only). Controlled by \code{forest}.}
}}

\item{forest}{For \code{type = "vi"}: which forest to display.
One of \code{"both"} (default), \code{"control"}, or \code{"treat"}.
When \code{"both"}, a named list of two \pkg{ggplot2} objects is returned.}

\item{n_vi}{Integer; number of top variables for \code{type = "vi"}.
Default \code{10}.}

\item{bayesian_bootstrap}{Logical; only used when \code{type = "ate"}. If
\code{TRUE} (default), the ATE posterior is computed by reweighting each
iteration's CATE vector with Dirichlet(1, ..., 1) weights, giving the
population ATE (PATE). If \code{FALSE}, equal \eqn{1/n} weights are used,
giving the mixed ATE (MATE).}

\item{...}{Additional arguments (currently unused).}
}
\value{
A \pkg{ggplot2} object, or (for \code{type = "vi"} with
\code{forest = "both"}) a named list with elements \code{control} and
\code{treat}.
}
\description{
Visualises posterior draws using \pkg{ggplot2}.
Requires the suggested package \pkg{ggplot2}.
}
\examples{
\donttest{
if (requireNamespace("ggplot2", quietly = TRUE)) {
  set.seed(1)
  n <- 60; p <- 5
  X <- matrix(rnorm(n * p), ncol = p)
  w <- rbinom(n, 1, 0.5)
  y <- X[, 1] + w * 1.5 * (X[, 2] > 0) + rnorm(n, sd = 0.5)

  fit <- CausalShrinkageForest(
    y = y,
    X_train_control = X, X_train_treat = X,
    treatment_indicator_train = w,
    prior_type_control = "horseshoe", prior_type_treat = "horseshoe",
    local_hp_control = 0.1, global_hp_control = 0.1,
    local_hp_treat  = 0.1, global_hp_treat  = 0.1,
    number_of_trees_control = 5, number_of_trees_treat = 5,
    N_post = 50, N_burn = 25,
    store_posterior_sample = TRUE,
    verbose = FALSE
  )

  plot(fit, type = "trace")
  plot(fit, type = "ate")
  plot(fit, type = "cate")
}
}
}
