logLik.vcmm_fit: Log-likelihood of a vcmm fit

View source: R/predict.R

logLik.vcmm_fitR Documentation

Log-likelihood of a vcmm fit

Description

Returns the marginal log-likelihood

\ell(\hat\beta, \hat\sigma_\varepsilon, \hat\Sigma_\alpha) = -\tfrac{n}{2}\log(2\pi) - \tfrac{1}{2}\log|\Sigma_y| - \tfrac{1}{2}(y - X\hat\beta)^{\top} \Sigma_y^{-1}(y - X\hat\beta),

evaluated at the fitted parameter values, with \Sigma_y = \sigma_\varepsilon^2 I + Z\,\Sigma_\alpha\,Z^{\top}. The value is computed once at convergence and cached on the fit object as object$marginal_loglik; this method simply retrieves it and attaches df and nobs attributes so that AIC() and BIC() work out of the box.

Usage

## S3 method for class 'vcmm_fit'
logLik(object, ...)

Arguments

object

A vcmm_fit object.

...

Unused.

Details

Degrees of freedom counted are p (fixed-effects, including all spline basis coefficients) plus the number of free variance-component parameters:

  • re_cov = "diag": 2 (\sigma_\varepsilon, \sigma_\alpha).

  • re_cov = "kronecker" / "separable": 1 + q_{\mathrm{left}}(q_{\mathrm{left}} + 1)/2 (\sigma_\varepsilon plus the free entries of \Sigma_{\mathrm{left}}). \Sigma_{\mathrm{right}} is held fixed at its user-supplied value and contributes 0 df.

Value

An object of class "logLik"; numeric scalar with df and nobs attributes.

References

Jalili, L. and Lin, L.-H. (2025). Scalable and Communication-Efficient Varying Coefficient Mixed-Effects Models.

Examples

set.seed(1)
n <- 400
t <- runif(n); x <- runif(n); Z <- matrix(rnorm(n * 3), n, 3)
y <- 2 + sin(2 * pi * t) * x +
     as.vector(Z %*% rnorm(3, sd = 0.5)) + rnorm(n, sd = 0.5)
fit <- vcmm(y, X = x, Z = Z, t = t,
            control = vcmm_control(sigma_eps = 0.5, sigma_alpha = 0.5))
logLik(fit)
AIC(fit)
BIC(fit)

cevcmm documentation built on July 24, 2026, 5:07 p.m.