% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ci_cat.R
\name{ci_cat}
\alias{ci_cat}
\title{Confidence intervals for fitted categorical AD models}
\usage{
ci_cat(fit, y = NULL, level = 0.95, parameters = "all")
}
\arguments{
\item{fit}{A fitted model object of class \code{"cat_fit"} from \code{fit_cat()}.}

\item{y}{Optional data matrix. If NULL, \code{fit$cell_counts} is used
(observed counts for closed-form fits; expected counts for EM fits).}

\item{level}{Confidence level (default 0.95).}

\item{parameters}{Which parameters to compute CIs for: "all" (default),
"marginal", or "transition".}
}
\value{
A list of class \code{"cat_ci"} containing:
\item{marginal}{Data frame of CIs for marginal parameters (if requested)}
\item{transition}{List of data frames of CIs for transition parameters (if requested)}
\item{level}{Confidence level used}
\item{settings}{Model settings from fit}
}
\description{
Computes Wald-based confidence intervals for the transition probability
parameters of a fitted categorical antedependence model.
}
\details{
Confidence intervals are computed using the Wald method based on the
asymptotic normality of maximum likelihood estimators.

For a probability estimate \eqn{\hat{\pi}} based on count N, the standard error is:
\deqn{SE(\hat{\pi}) = \sqrt{\frac{\hat{\pi}(1-\hat{\pi})}{N}}}

For conditional probabilities \eqn{\hat{\pi}_{j|i}} based on conditioning count
\eqn{N_i}, the standard error is:
\deqn{SE(\hat{\pi}_{j|i}) = \sqrt{\frac{\hat{\pi}_{j|i}(1-\hat{\pi}_{j|i})}{N_i}}}

The confidence interval is then:
\deqn{\hat{\pi} \pm z_{\alpha/2} \times SE(\hat{\pi})}

Note: CIs are truncated to the interval from 0 to 1 when they exceed these bounds.

Missing-data fits with \code{na_action = "marginalize"} are not currently
supported because observed cell counts are not stored for that path.
}
\examples{
\donttest{
# Fit a model
set.seed(123)
y <- simulate_cat(200, 5, order = 1, n_categories = 2)
fit <- fit_cat(y, order = 1)

# Compute confidence intervals
ci <- ci_cat(fit)
print(ci)

# Just marginal CIs
ci_marg <- ci_cat(fit, parameters = "marginal")
}

}
\references{
Agresti, A. (2013). Categorical Data Analysis (3rd ed.). Wiley.
}
\seealso{
\code{\link{fit_cat}}
}
