% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/PStrataModel.R
\name{PStrataModel}
\alias{PStrataModel}
\title{Define a Principal Stratification Model}
\usage{
PStrataModel(
  S.formula,
  Y.formula,
  Y.family,
  strata,
  ER = NULL,
  prior_intercept = prior_flat(),
  prior_coefficient = prior_normal(),
  prior_sigma = prior_inv_gamma(),
  prior_alpha = prior_inv_gamma(),
  prior_lambda = prior_inv_gamma(),
  prior_theta = prior_normal(),
  survival.time.points = 50
)
}
\arguments{
\item{S.formula}{formula for the stratum model (e.g., \code{Z + D ~ X1 + X2}).}

\item{Y.formula}{formula for the outcome model (e.g., \code{Y ~ X1 + X2}).}

\item{Y.family}{a \code{family} object (e.g., \code{gaussian()}, \code{survival("Cox")}).}

\item{strata}{strata definition: character vector, list of vectors, or list of lists.}

\item{ER}{exclusion restriction: character vector of strata names or logical vector.}

\item{prior_intercept, prior_coefficient, prior_sigma, prior_alpha, prior_lambda, prior_theta}{prior distributions for model parameters.}

\item{survival.time.points}{number of time points for survival outcomes.}
}
\value{
An object of class \code{PStrataModel}.
}
\description{
Creates a model specification for principal stratification analysis.
No data is required at this stage -- the specification is purely symbolic.
Use \code{\link{fit}} to estimate the model with data.
}
\examples{
# Non-compliance with three strata (never-taker, complier, always-taker)
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")
)
print(model)
summary(model)

\donttest{
# Fit the model (requires rstan and C++ compiler)
data(sim_data_normal)
ps_fit <- fit(model, data = sim_data_normal, chains = 2, iter = 500)
summary(ps_fit)
plot(ps_fit)

# Extract potential outcomes and contrasts
est <- estimate(ps_fit)
summary(est)
plot(est)

ctr <- contrast(ps_fit)
summary(ctr)
plot(ctr)
}
}
