| em_cat | R Documentation |
Fits categorical antedependence models with missing outcomes using the Expectation-Maximization (EM) algorithm for orders 0 and 1.
em_cat(
y,
order = 1,
blocks = NULL,
homogeneous = TRUE,
n_categories = NULL,
max_iter = 100,
tol = 1e-06,
epsilon = 1e-08,
safeguard = TRUE,
verbose = FALSE
)
y |
Integer matrix with n_subjects rows and n_time columns. Values are
category codes in |
order |
Antedependence order. Supported values are |
blocks |
Optional block/group vector of length |
homogeneous |
Logical. If |
n_categories |
Number of categories. If |
max_iter |
Maximum number of EM iterations. |
tol |
Convergence tolerance on absolute log-likelihood change. |
epsilon |
Small positive constant used for smoothing and numerical stability. |
safeguard |
Logical; if |
verbose |
Logical; if |
For complete data (no missing values), this function defers to
fit_cat with closed-form MLEs.
For missing data and orders 0/1, each EM iteration computes expected
sufficient statistics with a forward-backward E-step, then updates
probabilities by normalized expected counts in the M-step.
If safeguard = TRUE, a step-halving line search is applied to the
M-step update whenever the observed-data likelihood decreases.
A final E-step is run before returning so that log_l/AIC/BIC and
expected cell counts correspond exactly to the returned parameter values.
A cat_fit object with fields matching fit_cat.
In EM mode, cell_counts stores expected counts from the final
E-step, with settings$cell_counts_type = "expected".
fit_cat, logL_cat
set.seed(1)
y <- simulate_cat(n_subjects = 40, n_time = 5, order = 1, n_categories = 3)
y[sample(length(y), 10)] <- NA
fit <- em_cat(y, order = 1, n_categories = 3, max_iter = 20, tol = 1e-5)
fit$settings$na_action
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.