melissagwolf / dynamic

Dynamic Fit Index Cutoffs For Latent Variable Models
GNU Affero General Public License v3.0
14 stars 2 forks source link

Error in multi_add_HB(model) : object 'model2' not found #11

Closed jenny-terry closed 1 year ago

jenny-terry commented 1 year ago

Hi,

I have been getting the error: Error in multi_add_HB(model) : object 'model2' not found whenever I run cfaHB() or catHB() in the beta version (cfaHB() seems fine in the released version). I tried both functions with several different models, thinking something I was doing was breaking it, but I get the exact same error even when I run examples from the package webpages (copied below), so I think maybe it is a bug?

Example from https://github.com/melissagwolf/dynamic:

library(dynamic)
#Lavaan object example (manual = FALSE)
dat <- lavaan::HolzingerSwineford1939
lavmod <- "F1 =~ x1 + x2 + x3
          F2 =~ x4 + x5 + x6
          F3 =~ x7 + x8 + x9"
fit <- lavaan::cfa(lavmod,dat)
cfaHB(fit)

Example from https://rpubs.com/dmcneish/1025400:

library(lavaan)
dat <- lavaan::HolzingerSwineford1939
dat1 <- round(dat [,7:12])
lavmod <- "visual  =~ x1 + x2 + x3
                   textual =~ x4 + x5 + x6"
fit <- lavaan::cfa(model = lavmod, data = dat1,  ordered = T, estimator = "WLSMV")
lavaan::fitmeasures(fit, c("srmr", "rmsea.scaled", "cfi.scaled"))

dynamic::catHB(fit, plot=T)

Thanks for taking a look (and for this package and the super-helpful vignettes - they're really great)!

dmcneish18 commented 1 year ago

This was 100% my fault and it was nothing you were doing. I recently updated to code to remove/replace dplyr functions that had become deprecated after the latest dplyr update. In doing so, an errant "2" was added the end of one line of the multi-factor algorithm code, so all cfaHB and catHB broke down because it was looking for "model2" instead of "model".

I went through and removed the typo and it should work (hopefully) work now! If it does not or if you run into any other bugs, please don't hesitate to let us know!

Thanks for using the package and sorry for any frustration or inconvenience this may have caused you!