Error in if (categorical.flag) { : argument is of length zero

630 views
Skip to first unread message

Ian McPhail

unread,
Dec 20, 2023, 5:29:27 PM12/20/23
to lavaan
Hi, everyone.

I am having a similar issue post in the blavaan google group here: https://groups.google.com/g/blavaan/c/JPMK5uRxdWI

After updating lavaan (version lavaan_0.6-17), following running cfa.mi (either with lavaan.mi or semTools being the package loaded to handle multiply imputed datasets), when I attempt to run the summary() function, the following error occurs. 

Error in if (categorical.flag) { : argument is of length zero

All the other functions that I usually run (fitMeasures, lavTestLRT.mi, resid, modindices.mi) are working fine. I can also pull much of the information that summary() shows via the standardizedSolution() function, but it's the summary() function only that provides this error. So it seems that in updating lavaan, this error emerged, or at least this is my understanding because this error was not occurring previously.

I've updated all the packages in RStudio and have the latest version of R installed (4.3.2).

Any help would be greatly appreciated! Thanks,

Ian

Yves Rosseel

unread,
Dec 22, 2023, 11:43:06 AM12/22/23
to lav...@googlegroups.com
Would you be able to send me a minimal reprex producing this error?

Yves.
> --
> You received this message because you are subscribed to the Google
> Groups "lavaan" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to lavaan+un...@googlegroups.com
> <mailto:lavaan+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/lavaan/aa0ac3c3-cab3-49e9-8a00-d80809816fafn%40googlegroups.com <https://groups.google.com/d/msgid/lavaan/aa0ac3c3-cab3-49e9-8a00-d80809816fafn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Terrence Jorgensen

unread,
Jan 11, 2024, 7:22:25 AM1/11/24
to lavaan
when I attempt to run the summary() function, the following error occurs. 

Error in if (categorical.flag) { : argument is of length zero

This was due to lavaan adding attr(., "categorical") and attr(., "parameterization") to parameterEstimates(..., output = "text"), which is what summary() calls.  I now added those in semTools and lavaan.mi, so the development versions on GitHub work again.

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Ian McPhail

unread,
Jan 14, 2024, 3:55:46 PM1/14/24
to lavaan
Drs. Rosseel & Jorgensen.

Apologies for my slow reply and not providing a reprex, these emails were sent to my spam folder. And thank you for the fix! Again, the semTools and lavaan.mi packages have made a lot possible in my program of research, and I am infinitely grateful for all your efforts!

Ian.

Aashna Waiwood

unread,
Jan 19, 2024, 5:18:08 PM1/19/24
to lavaan
Good evening,

I wanted to follow up on this thread, which I was watching. I had the same erorr as Ian, and I'm thrilled to report that the developmental version of GitHub with the update now allows me to produce the output from the "summary" function. However, I am still having an error where when I run the parameterEstimates() command, I receive output containing the lhs, operator, rhs, and label, but none of the actual values of any of the parameters (e.g., estimates, 95% CIs, etc.). In particular, I am interested in getting the 95% CIs for my pub. Is there a solution for resolving this related to your note on " lavaan adding attr(., "categorical") and attr(., "parameterization") to parameterEstimates(..., output = "text")"? 

Any help would be appreciated, thank you! 
Aashna

Terrence Jorgensen

unread,
Jan 20, 2024, 3:08:53 AM1/20/24
to lavaan
I am still having an error where when I run the parameterEstimates() command

The parameterEstimates() function is for class?lavaan objects, not for class?lavaan.mi objects.
I made a table of how to find equivalent functionality for lavaan.mi objects, in the separate lavaan.mi package I am working on:
But I am also working on a conversion function in the new package that will eventually allow me to write parameterEstimates.mi() and standardizedSolution.mi() functions.  Hopefully by end of 2024, but hard to predict when I will have the free time.

Aashna Waiwood

unread,
Jan 20, 2024, 10:08:27 AM1/20/24
to lavaan
Thank you for your response, I appreciate your time and the equivalent functionality table you have linked! I look forward to potential updates later this year. 

E.J. Heeman

unread,
Jan 28, 2024, 6:22:32 AM1/28/24
to lavaan
Dear Dr. Jorgensen, Dr. Rosseel,

Thank you for the semTools and lavaan.mi packages!

I get the same error when running the summary() function after successfully running runMI().  This was no issue before I updated to the latest versions of Rstudio and Lavaan (same as mentioned by Ian McPhail). 
My current semTools version is 0.5-6. Dr. Jorgensen mentioned that the development version of semTools on GitHub should now work again, yet I have issues downloading it through  remotes::install_github("simsem/semTools/semTools"),see error: Downloading GitHub repo simsem/semTools@HEAD Error in utils::download.file(url, path, method = method, quiet = quiet, : download from 'https://api.github.com/repos/simsem/semTools/tarball/HEAD' failed
Is there any other way to get access to the semTools development version that has now added attr(., "categorical") and attr(., "parameterization") to parameterEstimates(..., output = "text")?

Thank you for your time!

Emma

Terrence Jorgensen

unread,
Jan 28, 2024, 7:04:46 AM1/28/24
to lavaan
remotes::install_github("simsem/semTools/semTools"),see error:  
Downloading GitHub repo simsem/semTools@HEAD 
Error in utils::download.file(url, path, method = method, quiet = quiet, : download from 'https://api.github.com/repos/simsem/semTools/tarball/HEAD' failed

Strange.  I attached the package source (if Google doesn't block it).  If you can download it, you can install the version saved on your computer:

install.packages("semTools_0.5-6.932.tar.gz", type = "source", repos = NULL)
semTools_0.5-6.932.tar.gz

E.J. Heeman

unread,
Jan 28, 2024, 10:38:17 AM1/28/24
to lavaan
Dear Dr. Jorgensen,

It worked after I installed the newest version via my computer. Thank you, I very much appreciate it!

Best,

Emma

Jessica Ramos

unread,
Feb 21, 2024, 11:15:20 AM2/21/24
to lavaan

Dear Dr. Jorgensen,

Thank you very much for your great work and the packages. 
Prior to installing the latest version, I encountered the same error message mentioned earlier. Fortunately, after the update, functions such as summary()and fitMeasures() are now operating smoothly. However, I am facing an issue with the modindices.mi() when attempting to request modification indices. The error message I receive is as follows:
Error in inherits(nR) : argument "what" is missing, with no default
Is there a solution available for addressing this issue, or has anyone else encountered and successfully navigated through this problem?

Any help is very much appreciated!

Best,
Jessica
Reply all
Reply to author
Forward
0 new messages