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

Issues with blavaan #627

Open
strengejacke opened this issue Oct 2, 2023 · 2 comments
Open

Issues with blavaan #627

strengejacke opened this issue Oct 2, 2023 · 2 comments
Assignees
Labels
waiting for response 💌 Need more information from people who submitted the issue

Comments

@strengejacke
Copy link
Member

strengejacke commented Oct 2, 2023

Hm, there were actually quite some bugs in package functions which were not captured by the CI tests? @mattansb Here's an example that seems to have worked in the past (at least, we had a test for it), but now no longer works:

library(bayestestR)
library(blavaan)
#> Loading required package: Rcpp
#> This is blavaan 0.5-1
#> On multicore systems, we suggest use of future::plan("multicore") or
#>   future::plan("multisession") for faster post-MCMC computations.

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
  )
}))

bayesfactor_models(bfit, bfit2)
#> Warning: Bayes factors might not be precise.
#>   For precise Bayes factors, sampling at least 40,000 posterior samples is
#>   recommended.
#> Error in apply(diffs, 2, sum): dim(X) must have a positive length

Created on 2023-10-02 with reprex v2.0.2

Originally posted by @strengejacke in #625 (comment)

@mattansb
Copy link
Member

This is actually an error in blavaan:

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

Opened an issue over there (ecmerkle/blavaan#68)

@strengejacke strengejacke added waiting for response 💌 Need more information from people who submitted the issue and removed bug 🐛 Something isn't working labels Oct 24, 2023
@mattansb
Copy link
Member

This was recently discussed at the thread below, and it should be fixed on github.

So I think we can skip this test for now, but leave this issue open until that fix is on CRAN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for response 💌 Need more information from people who submitted the issue
Projects
None yet
Development

No branches or pull requests

3 participants