% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/contrast.R
\name{contrast}
\alias{contrast}
\alias{contrast.PSEstimate}
\alias{contrast.PStrataFit}
\title{Contrast Potential Outcomes}
\usage{
contrast(object, ...)

\method{contrast}{PSEstimate}(
  object,
  S = NULL,
  Z = NULL,
  T = NULL,
  type = c("all", "sequential", "cycle"),
  ...
)

\method{contrast}{PStrataFit}(
  object,
  S = NULL,
  Z = NULL,
  T = NULL,
  type = c("all", "sequential", "cycle"),
  ...
)
}
\arguments{
\item{object}{A \code{PSEstimate}, \code{PSContrast}, or
\code{PStrataFit} object. If \code{PStrataFit}, \code{estimate()}
is called automatically.}

\item{...}{Additional arguments passed to \code{estimate()} when
\code{object} is a \code{PStrataFit}.}

\item{S}{Strata to contrast. \code{TRUE} for all pairwise, or a
numeric/logical index vector. \code{NULL} (default) = no contrast.}

\item{Z}{Treatment arms to contrast. \code{TRUE} for all pairwise.}

\item{T}{Time points to contrast (survival only).}

\item{type}{\code{"all"} (all pairwise), \code{"sequential"}
(consecutive pairs), or \code{"cycle"} (consecutive + wrap-around).}
}
\value{
A \code{PSContrast} object (inherits from \code{PSEstimate}).
}
\description{
Compute pairwise differences of posterior potential outcomes
along strata, treatment arms, or time points.
}
\examples{
\donttest{
data(sim_data_normal)
model <- PStrataModel(
  S.formula = Z + D ~ 1,
  Y.formula = Y ~ 1,
  Y.family  = gaussian(),
  strata    = c(n = "00", c = "01", a = "11"),
  ER        = c("n", "a")
)
ps_fit <- fit(model, data = sim_data_normal, chains = 2, iter = 500)

# Treatment effect (Z contrast) for each stratum
ctr_z <- contrast(ps_fit, Z = TRUE)
summary(ctr_z)
plot(ctr_z)

# Stratum contrasts for each treatment arm
ctr_s <- contrast(ps_fit, S = TRUE)
summary(ctr_s)
}
}
