Fits an AD(0), AD(1), or AD(2) model for Gaussian longitudinal data
by maximum likelihood. Missing values can be handled by complete-case
deletion or by EM (see em_gau for an explicit EM wrapper).
Usage
fit_gau(
y,
order = 1,
blocks = NULL,
na_action = c("fail", "complete", "em"),
estimate_mu = TRUE,
em_max_iter = 100,
em_tol = 1e-06,
em_verbose = FALSE,
...
)Arguments
- y
Numeric matrix (n_subjects x n_time). May contain NA.
- order
Integer 0, 1, or 2.
- blocks
Optional vector of block membership (length n_subjects).
- na_action
One of "fail", "complete", or "em".
- estimate_mu
Logical, whether to estimate mu (default TRUE).
- em_max_iter
Maximum EM iterations (only used when na_action = "em").
- em_tol
EM convergence tolerance (only used when na_action = "em").
- em_verbose
Logical, print EM progress (only used when na_action = "em").
- ...
Passed through to the EM fitter.
Details
For missing data with na_action = "em", AD orders 0 and 1 are the
primary production path. AD order 2 is available, but the current EM
implementation uses simplified second-order updates and should be treated as
provisional for high-stakes inference.
For observed-data likelihood evaluation under MAR without fitting, use
logL_gau with na_action = "marginalize". In contrast,
fit_gau handles missingness via complete-case fitting
(na_action = "complete") or EM (na_action = "em").
Examples
set.seed(1)
y <- simulate_gau(n_subjects = 30, n_time = 5, order = 1, phi = 0.3)
fit <- fit_gau(y, order = 1)
fit$log_l
#> [1] -190.3954
y_miss <- y
y_miss[1, 2] <- NA
fit_em <- fit_gau(y_miss, order = 1, na_action = "em", em_max_iter = 20)
fit_em$settings$na_action
#> NULL