Hello!
I did some testing and found that the issue was actually caused by the fact that specifying a multigroup analysis automatically gets lavaan to estimate intercepts (meanstructure = TRUE).
I managed to use one of the provided datasets in lavaan to create an example to illustrate my issue, which is that the a particular model exhibits different levels of fit when intercepts are estimated.
In this particular case, when the model is fit without specifying "meanstructure = TRUE", I receive a warning.
## Warning in lavaan::lavaan(model = model, data = PoliticalDemocracy, model.type = "sem", : lavaan WARNING:
## the optimizer warns that a solution has NOT been found!
However, the warning seemingly goes away when I specify "meanstructure = TRUE".
Below is the full code to replicate the issue (also attached as a knitted html file). I would think the problem is actually caused by the introduction of the latent factor "common" that is trying to account for common method bias using an unmeasured latent method construct, the problem disappears when I remove that factor.
## The industrialization and Political Democracy Example
## Bollen (1989), page 332
model <- '
# latent variable definitions
dem60 =~ y1 + y2 + y3 + y4
dem65 =~ y5 + y6 + y7 + y8
common =~ y1 + y2 + y3 + y4 + y5 + y6 + y7 + y8
# latent correlations
common ~~ 0*dem60 + 0*dem65
dem65 ~ dem60
'
fit <- sem(model, data = PoliticalDemocracy)
# fit produces a warning but fit2 does not
fit2 <- sem(model, data = PoliticalDemocracy, meanstructure = TRUE)
Here is also my session info.
## R version 4.0.5 (2021-03-31)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Catalina 10.15.7
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] lavaan_0.6-8
##
## loaded via a namespace (and not attached):
## [1] digest_0.6.27 R6_2.5.0 jsonlite_1.7.2 stats4_4.0.5
## [5] magrittr_2.0.1 evaluate_0.14 rlang_0.4.10 stringi_1.5.3
## [9] jquerylib_0.1.3 bslib_0.2.4 pbivnorm_0.6.0 rmarkdown_2.11
## [13] tools_4.0.5 stringr_1.4.0 xfun_0.22 yaml_2.2.1
## [17] compiler_4.0.5 mnormt_2.0.2 tmvnsim_1.0-2 htmltools_0.5.1.1
## [21] knitr_1.36 sass_0.3.1