Log-likelihood for Gaussian AD models (with missing data support)
Source:R/loglik_gau.R
logL_gau.RdComputes the log-likelihood for Gaussian antedependence models of order 0, 1, or 2. Supports missing data under MAR assumption via na_action parameter.
Usage
logL_gau(
y,
order,
mu = NULL,
phi = NULL,
sigma = NULL,
blocks = NULL,
tau = 0,
na_action = c("fail", "complete", "marginalize")
)Arguments
- y
Numeric matrix with n_subjects rows and n_time columns. May contain NA.
- order
Antedependence order, one of 0, 1, or 2.
- mu
Mean vector (length n_time).
- phi
Dependence coefficient(s). For order 1: vector of length n_time-1. For order 2: matrix with 2 columns or vector of length 2*(n_time-2).
- sigma
Innovation standard deviations (length n_time).
- blocks
Integer vector of block membership (length n_subjects), or NULL.
- tau
Block effects, first element constrained to zero
- na_action
How to handle missing values:
fail: Error if any NA is present (default)complete: Use only complete casesmarginalize: Compute observed-data likelihood
Details
For complete data (no NA), all three na_action options give the same result.
For missing data:
marginalize: Uses MVN marginalization to compute P(Y_obs). This is the correct observed-data likelihood for MAR missing data.
complete: Removes subjects with any missing values. May lose information.
fail: Stops with error. Useful to ensure no missing data present.
Examples
set.seed(1)
y <- simulate_gau(n_subjects = 30, n_time = 5, order = 1, phi = 0.3)
fit <- fit_gau(y, order = 1)
logL_gau(y, order = 1, mu = fit$mu, phi = fit$phi, sigma = fit$sigma)
#> [1] -190.3954