% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/methods.R
\name{plot.causalmixgpd_causal_fit}
\alias{plot.causalmixgpd_causal_fit}
\alias{plot.mixgpd_fit}
\alias{plot.mixgpd_fitted}
\title{Plot the treated and control outcome fits from a causal model}
\usage{
\method{plot}{causalmixgpd_causal_fit}(x, arm = "treated", ...)

\method{plot}{mixgpd_fit}(x, family = "traceplot", params = NULL, nLags = 50, ...)

\method{plot}{mixgpd_fitted}(x, y = NULL, ...)
}
\arguments{
\item{x}{Object of class \code{mixgpd_fitted} from \code{fitted.mixgpd_fit()}.}

\item{arm}{Integer or character; \code{1} or \code{"treated"} for treatment,
\code{0} or \code{"control"} for control, or \code{"both"} for both arms.}

\item{...}{Additional arguments (ignored).}

\item{family}{Character vector of plot names (ggmcmc plot types)
or a single one. The default \code{"traceplot"} returns one diagnostic.
Use \code{"all"} to include all plots supported for the available number
of chains/parameters. \code{"auto"} is accepted as an alias for the
default single diagnostic. Supported types:
\itemize{
\item \code{"histogram"}: posterior histograms
\item \code{"density"}: posterior density curves
\item \code{"traceplot"}: MCMC trace plots
\item \code{"running"}: running mean plots
\item \code{"compare_partial"}: partial chain comparisons
\item \code{"autocorrelation"}: autocorrelation plots
\item \code{"crosscorrelation"}: cross-correlation matrix
\item \code{"Rhat"}: Gelman--Rubin R-hat (2+ chains)
\item \code{"grb"}: Gelman--Rubin--Brooks (2+ chains)
\item \code{"effective"}: effective sample size
\item \code{"geweke"}: Geweke diagnostic
\item \code{"caterpillar"}: caterpillar/forest plots
\item \code{"pairs"}: pairwise scatter plots (2+ params)
}}

\item{params}{Optional parameter selector:
\itemize{
\item character vector of parameter patterns (exact names
or partial matches)
\item a single regex string
(e.g. \code{"alpha|threshold|tail_"})
\item \code{NULL} (default): plots all monitored parameters
}}

\item{nLags}{Number of lags for autocorrelation (ggmcmc).}

\item{y}{Ignored; included for S3 compatibility.}
}
\value{
The result of the underlying plot call (invisibly).

Invisibly returns a named list of ggplot objects.

Invisibly returns a list with the two plots.
}
\description{
\code{plot.causalmixgpd_causal_fit()} is a convenience router to the
underlying one-arm diagnostic plots for the treated and control fits.

Uses ggmcmc to produce standard MCMC diagnostic plots. Works with 1+ chains.

S3 method for visualizing fitted values from \code{fitted.mixgpd_fit()}.
Produces a 2-panel figure: Q-Q plot and residuals vs fitted.
}
\details{
Each arm-specific outcome model is itself a \code{mixgpd_fit}, so this method
delegates to \code{plot.mixgpd_fit()} for the selected arm. With \code{arm = "both"},
it returns a named list of treated and control diagnostics so the two fitted
outcome models can be assessed side by side.

These are MCMC diagnostics for the nuisance outcome models, not plots of
causal estimands. Use \code{plot()} on objects from
\code{predict.causalmixgpd_causal_fit()}, \code{qte()}, or \code{ate()} when the goal is to
visualize treatment effects rather than chain behavior.

The supported plots diagnose posterior simulation quality rather than data fit.
Depending on the selected \code{family}, they show chain traces, marginal posterior
densities, autocorrelation, cross-correlation, running means, or Gelman-style
convergence summaries for the monitored parameters.

These graphics should be read before interpreting posterior summaries or
treatment-effect results. Poor mixing or strong autocorrelation in the MCMC
output can invalidate downstream summaries even when the fitted model itself
is correctly specified.

These diagnostics compare the fitted values implied by the posterior summary
on the training design against the observed responses. The first panel checks
how closely fitted and observed values align, while the second panel looks for
residual structure that would indicate lack of fit or remaining mean trends.

This method is distinct from posterior predictive simulation on new data. It
is a training-sample diagnostic built from \code{fitted.mixgpd_fit()} and the
corresponding residuals.
}
\examples{
\donttest{
y <- abs(stats::rnorm(25)) + 0.1
bundle <- build_nimble_bundle(y = y, backend = "sb", kernel = "normal",
                             GPD = TRUE, components = 3,
                             mcmc = list(niter = 100, nburnin = 50, thin = 1, nchains = 1))
fit <- run_mcmc_bundle_manual(bundle)
plot(fit, family = c("traceplot", "density"))
}
}
\seealso{
\code{\link{plot.mixgpd_fit}},
\code{\link{predict.causalmixgpd_causal_fit}}, \code{\link{ate}},
\code{\link{qte}}.
}
