ecmerkle/blavaan

`blavCompare` errors

mattansb opened this issue · 2 comments

This code use to work, but now errors, any idea why?

library(bayestestR)
library(blavaan)

data("PoliticalDemocracy", package = "lavaan")

model <- "
  # latent variable definitions
  dem60 =~ y1 + a*y2
  dem65 =~ y5 + a*y6

  # regressions
  dem65 ~ dem60

  # residual correlations
  y1 ~~ y5
"

model2 <- "
  # latent variable definitions
  dem60 =~ y1 + a*y2
  dem65 =~ y5 + a*y6

  # regressions
  dem65 ~ 0*dem60

  # residual correlations
  y1 ~~ 0*y5
"
suppressWarnings(capture.output({
  bfit <- blavaan::bsem(model,
                        data = PoliticalDemocracy,
                        n.chains = 1, burnin = 50, sample = 100
  )
  bfit2 <- blavaan::bsem(model2,
                         data = PoliticalDemocracy,
                         n.chains = 1, burnin = 50, sample = 100
  )
}))

blavaan::blavCompare(bfit, bfit2)
#> Error in apply(diffs, 2, sum) : dim(X) must have a positive length

Thanks for the report! This was recently discussed at the thread below, and it should be fixed on github. A workaround for the current CRAN version is to add meanstructure = TRUE to bsem().

https://groups.google.com/g/blavaan/c/n9e_x5995nQ/m/Wrk02FG_AwAJ

If you still encounter the problem, please reopen this issue!

Thanks Ed!