blavaan icon indicating copy to clipboard operation
blavaan copied to clipboard

Error in lav2standata(lavobject) : object 'ptot' not found

Open phlegmy opened this issue 10 months ago • 4 comments

Hi, I am running a 2 level model in blavaan but I am getting the following error: [1] "Error in lav2standata(lavobject) : object 'ptot' not found\n" attr(,"class") [1] "try-error" attr(,"condition") <simpleError in lav2standata(lavobject): object 'ptot' not found> Error in blavaan(bmsem2, pisa_sgstusch, cluster = "CNTSCHID", target = "stan", : blavaan ERROR: problem with translation from lavaan to MCMC syntax.

I'm working on Rstudio with the code:

model<- ' level: within eta1_w=~y1 + y2 + y3 eta2_w=~y4 + y5 + y6

eta2_w~ eta1_w

level:between eta1_b=~ y1 + y2 + y3 eta2_b=~y4 + y5 + y6 eta3_b=~y7+y8+y9

eta2_b~ eta1_b + eta3_b eta3_b~eta1_b ' bsem(model, data, cluster')

It seems like the error is about an object 'ptot' in lav2standata which is not part of my codes or data. Would greatly appreciate your kind support please. Thanks!

phlegmy avatar Mar 25 '24 03:03 phlegmy

Thanks for the report! The ptot object is internal to blavaan and is used to translate the model to Stan. So something is wrong, but I haven't been able to reproduce the error for this type of model. It might help to know what version of blavaan and lavaan you are using (say, using sessionInfo()), and it would help to see the dataset if you can share it.

ecmerkle avatar Mar 25 '24 16:03 ecmerkle

I looked at this some more, and I am guessing you have missing data (NA values). If so, blavaan cannot yet handle missing data in two-level models. But I should improve the error handling here.

ecmerkle avatar Mar 28 '24 18:03 ecmerkle

Hi, thanks for getting back. Yes, I did have missing data. Let me try without and see if it works.

phlegmy avatar Mar 30 '24 15:03 phlegmy

No problem, and if you can install from github, it should now automatically do listwise deletion and display a NOTE about it.

Instructions for installing from github are at the bottom of the repo's page.

ecmerkle avatar Mar 30 '24 15:03 ecmerkle

The fix described above is now available in blavaan 0.5-4 on CRAN. If you have further problems here, please reopen!

ecmerkle avatar Apr 28 '24 19:04 ecmerkle