Skip to contents

Computes Wald-based confidence intervals for the transition probability parameters of a fitted categorical antedependence model.

Usage

ci_cat(fit, y = NULL, level = 0.95, parameters = "all")

Arguments

fit

A fitted model object of class "cat_fit" from fit_cat().

y

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

level

Confidence level (default 0.95).

parameters

Which parameters to compute CIs for: "all" (default), "marginal", or "transition".

Value

A list of class "cat_ci" containing:

marginal

Data frame of CIs for marginal parameters (if requested)

transition

List of data frames of CIs for transition parameters (if requested)

level

Confidence level used

settings

Model settings from fit

Details

Confidence intervals are computed using the Wald method based on the asymptotic normality of maximum likelihood estimators.

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

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

The confidence interval is then: $$\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 na_action = "marginalize" are not currently supported because observed cell counts are not stored for that path.

References

Agresti, A. (2013). Categorical Data Analysis (3rd ed.). Wiley.

See also

Examples

if (FALSE) { # \dontrun{
# 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")
} # }