Skip to content

Commit

Permalink
ppmc, resolve chisq ambiguity for ordinal models, per #45
Browse files Browse the repository at this point in the history
  • Loading branch information
ecmerkle committed Mar 22, 2022
1 parent b0c191e commit 86b05df
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: blavaan
Title: Bayesian Latent Variable Analysis
Version: 0.4-2.912
Version: 0.4-2.913
Authors@R: c(person(given = "Edgar", family = "Merkle",
role = c("aut", "cre"),
email = "[email protected]",
Expand Down
13 changes: 13 additions & 0 deletions R/ctr_ppmc.R
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,18 @@ ppmc <- function(object, thin = 1, fit.measures = c("srmr","chisq"),
stop('blavaan ERROR: The "discFUN" argument must be a (list of) function(s).')
}

## differentiate between multiple possible chisq stats
if (length(fit.measures) == 1L & blavInspect(object, "categorical")) {
if (fit.measures == "chisq") {
## add another so that the dwls chisq from lavaan is used
## (due to the way blav_model_loglik is structured)
fit.measures <- c("chisq", "chisq.scaled")
} else if (fit.measures == "marglogl") {
## approximate the marginal lrt
fit.measures <- "chisq"
}
}

## if we have lv samples, send the full object in for convenience functions involving lvs
fullobj <- NULL
jagtarget <- lavInspect(object, "options")$target == "jags"
Expand Down Expand Up @@ -662,6 +674,7 @@ ppmc <- function(object, thin = 1, fit.measures = c("srmr","chisq"),

## names for each discFUN
if (is.null(names(discFUN))) names(discFUN) <- paste0("discFUN", seq_along(discFUN))

## pass names to other lists
for (d in seq_along(discFUN)) {
names(DIMS) <- names(PPP) <- names(OBS) <- names(SIM) <- names(discFUN)
Expand Down
5 changes: 2 additions & 3 deletions man/ppmc.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ summary.ppmc(object, discFUN, dist = c("obs","sim"),
discrepancy measures returned by \code{\link[lavaan]{fitMeasures}}. Ignored
unless \code{discFUN} is \code{NULL}, but users may include
\code{fitMeasures} in the \code{list} of discrepancy functions in
\code{discFUN}. If the first measure is either \code{"logl"} or
\code{"chisq"}, only the \eqn{\chi^2} fit statistic's posterior (predictive)
distributions will be returned.}
\code{discFUN}. For ordinal models, the \code{"logl"} or \code{"chisq"}
computations are done via lavaan.}
\item{discFUN}{\code{function}, or a \code{list} of functions, that can be
called on an object of class \code{\linkS4class{lavaan}}. Each function
must return an object whose \code{\link{mode}} is \code{numeric}, but may
Expand Down

0 comments on commit 86b05df

Please sign in to comment.