% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ordinal_khaos.R
\name{predict.ordinal_khaos}
\alias{predict.ordinal_khaos}
\title{Predict Method for class \code{ordinal_khaos}}
\usage{
\method{predict}{ordinal_khaos}(
  object,
  newdata = NULL,
  mcmc.use = NULL,
  type = c("class", "prob", "latent"),
  aggregate = FALSE,
  ...
)
}
\arguments{
\item{object}{An object of class \code{ordinal_khaos} returned by \code{ordinal_khaos()}.}

\item{newdata}{A data frame or matrix of predictors on the same scale and with
the same columns as used for fitting. If \code{NULL}, uses \code{object$X}.}

\item{mcmc.use}{Integer vector of posterior draw indices to use. If \code{NULL},
uses all stored draws (i.e., \code{seq_along(object$nbasis)}).}

\item{type}{Character; one of \code{"prob"}, \code{"class"}, or \code{"latent"}.
\code{"prob"} returns category probabilities \eqn{P(Y=k \mid x)} for
\eqn{k=1,\dots,K}. \code{"class"} returns MAP classes. \code{"latent"} returns
the latent mean \eqn{f(x)} (i.e., \eqn{B(x)\beta}) for each draw.}

\item{aggregate}{Logical (default \code{FALSE}); if \code{TRUE}, averages results across the
selected MCMC draws (probabilities are averaged; classes are aggregated by
simple voting; latent means are averaged). If \code{FALSE}, returns per-draw
arrays.}

\item{...}{Unused; included for method compatibility.}
}
\value{
If \code{type = "prob"} and \code{aggregate = TRUE}, an \code{nrow(newdata) x K}
numeric matrix of posterior mean category probabilities. If \code{aggregate = FALSE},
a 3-D array of dimension \code{(#draws) x nrow(newdata) x K}.

If \code{type = "class"} and \code{aggregate = TRUE}, an integer vector of length
\code{nrow(newdata)} with MAP classes aggregated by voting across draws. If
\code{aggregate = FALSE}, a \code{(#draws) x nrow(newdata)} integer matrix of
per-draw MAP classes.

If \code{type = "latent"}, returns the latent mean(s) \eqn{f(x)}: a numeric vector
of length \code{nrow(newdata)} if \code{aggregate = TRUE}, or a
\code{(#draws) x nrow(newdata)} numeric matrix otherwise.

A numeric matrix of posterior predictive samples, with rows corresponding
to samples and columns corresponding to observations.
}
\description{
Compute posterior predictive quantities for an ordinal probit BA-PCE model.
For each selected MCMC draw, the method builds the polynomial chaos basis,
forms the linear predictor \eqn{f(x) = B(x)\beta}, reconstructs the ordered
cutpoints, and returns either category probabilities, MAP classes, or latent
means. Results can be averaged across draws or returned per-draw.
}
\details{
Let \eqn{Z = f_\beta(X) + \varepsilon} with \eqn{\varepsilon \sim \mathcal{N}(0,1)} and
ordered cutpoints \eqn{\gamma_0=-\infty < \gamma_1 < \cdots < \gamma_{K-1} < \gamma_K=\infty}.
For a new input \eqn{x}, the category probabilities are
\deqn{P(Y=k\mid x) = \Phi(\gamma_k - f(x)) - \Phi(\gamma_{k-1} - f(x)).}
The function reconstructs the full cutpoint vector internally. If the fitted
object stored \eqn{\gamma_1,\dots,\gamma_{K-1}} then these are used directly;
if it stored only \eqn{\gamma_2,\dots,\gamma_{K-1}} (with \eqn{\gamma_1 \equiv 0})
the missing fixed cutpoint is inserted automatically.
}
\examples{
\donttest{
# Toy example (X scaled to [0,1])
set.seed(1)
X <- lhs::maximinLHS(200, 3)
# Suppose y has K=4 ordered categories:
fit <- ordinal_khaos(X, sample(1:4, 200, replace=TRUE),
                     nmcmc = 2000, nburn = 1000, thin = 2, verbose = FALSE)

# Posterior mean probabilities for each class
p_hat <- predict(fit, newdata = X, type = "prob", aggregate = TRUE)

# MAP classes (aggregated across draws)
y_hat <- predict(fit, newdata = X, type = "class")

# Latent mean f(x)
f_hat <- predict(fit, newdata = X, type = "latent")
}

}
\references{
Hoff, Peter D. (2009). \emph{A First Course in Bayesian Statistical Methods}.
Springer. (See ordinal probit data augmentation.)

Francom, Devin, and Bruno Sanso (2020). "BASS: An R package for fitting and
performing sensitivity analysis of Bayesian adaptive spline surfaces."
\emph{Journal of Statistical Software} 94. LA-UR-20-23587.
}
\seealso{
\code{\link{ordinal_khaos}} for model fitting.
}
