Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blavCompare errors #68

Closed
mattansb opened this issue Oct 24, 2023 · 2 comments
Closed

blavCompare errors #68

mattansb opened this issue Oct 24, 2023 · 2 comments

Comments

@mattansb
Copy link

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
@ecmerkle
Copy link
Owner

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!

@mattansb
Copy link
Author

Thanks Ed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants