R/method-others.R

Defines functions coef_inlavaan call_next_lavaan_method

call_next_lavaan_method <- function(object, ...) {
  class(object) <- "lavaan"
  callNextMethod()
}

# Loading blavaan (Suggests; used side-by-side with INLAvaan in compare_mcmc()
# workflows and in this package's own tests) overwrites lavaan's own
# coef,lavaan-method in the live session with a stale copy that calls the
# unexported lav_object_inspect_coef()/add.labels()/add.class() signature,
# even when a newer lavaan (with lav_inspect_coef()/add_labels()/add_class())
# is installed and was in effect before blavaan's namespace loaded. This is a
# cross-package method-table collision, not a version-drift issue on the
# INLAvaan object itself, so no amount of faithful fit0 recomposition avoids
# it: callNextMethod() would dispatch to whichever definition is currently
# registered for "lavaan", which blavaan can silently replace out from under
# us. Call the lavaan internal directly instead, same as the
# log-likelihood/gradient call sites.
coef_inlavaan <- function(object, ...) {
  dots <- list(...)
  type <- dots$type %||% "free"
  lavaan___lav_inspect_coef(
    object,
    type = type,
    add_labels = TRUE,
    add_class = TRUE
  )
}

#' @name coef
#' @rdname INLAvaan-class
#' @aliases coef,INLAvaan-method
#' @export
setMethod("coef", "INLAvaan", coef_inlavaan)

#' @name nobs
#' @rdname INLAvaan-class
#' @aliases nobs,INLAvaan-method
#' @export
setMethod("nobs", "INLAvaan", call_next_lavaan_method)

Try the INLAvaan package in your browser

Any scripts or data that you put into this service are public.

INLAvaan documentation built on Oct. 2, 2026, 1:07 a.m.