semTools::compareFit() with summary()-Function

842 views
Skip to first unread message

Axel Zinkernagel

unread,
May 31, 2021, 5:35:51 AM5/31/21
to lavaan
Hi all,

we are using the compareFit()-Function in our lectures. For many students this works quite well, however ~10% do not get an output table when using the summary()-Function with the return-Object of the compareFit()-Function. Unistalling and reinstalling lavaan and semTools (Updating R, etc.) sometimes helps, but not in every case.

So they get the result:

Length Class Mode
1          FitDiff     S4

As far as I understand, the registering for FitDiff-Objects of the generic summary()-Funktion fails. Does anybody know how register it correctly, or to workaroud this problem?

Thank you very much,

Axel

Pat Malone

unread,
May 31, 2021, 9:41:30 AM5/31/21
to lav...@googlegroups.com
Axel,

Is the syntax identical for every student? Can you show us the syntax leading up to the result?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/fdd8397a-9c9b-457d-afe0-252f0651bf32n%40googlegroups.com.


--
Patrick S. Malone, PhD
Sr Research Statistician, FAR HARBΦR
This message may contain confidential information; if you are not the intended recipient please notify the sender and delete the message.

Mauricio Garnier-Villarreal

unread,
May 31, 2021, 10:53:09 AM5/31/21
to lavaan
This seems like an issue of the R sessions not knowing the summary types.

Can be caused if you are not loading semTools with library(semTools). So if you call the function like semTools::compareFit(), R will called the right function even if semTools hasent being loaded, but R doesnt have the summary method because you havent loaded the package

My recommendation, have the run it with the library line, and without the semTools:: , this way you will be sure that they are using the loaded functions. Because of they havent loaded the package it will tell them that there is no compareFit function

Axel Zinkernagel

unread,
Jun 1, 2021, 1:29:11 AM6/1/21
to lavaan
Dear Pat and Mauricio,

thanks for your quick and helpful reply! Indeed, the package has to be loaded via the library()-Funktion.

Works:

library(semTools)
summary(compareFit(fit1, fit2, fit3, fit4))

Doesn't work:

#library(semTools)
summary(semTools::compareFit(fit1, fit2, fit3, fit4))

(in this case the class of the object is returned)

Best,

Axel

Terrence Jorgensen

unread,
Jun 2, 2021, 11:25:42 AM6/2/21
to lavaan
FYI, the development version is a little more consistent about what is returned by compareFit() and its summary() method.

devtools::install_github("simsem/semTools/semTools")

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam
http://www.uva.nl/profile/t.d.jorgensen

Message has been deleted

zure...@googlemail.com

unread,
Oct 19, 2022, 4:47:24 AM10/19/22
to lavaan
After a year the suggested solution worked I now again get the Object Output as described by Axel. I cannot solve it neither by loading the package directly before requesting the summary of compareFit nor by the installation of the development version. 
Does anybody have an idea how to solve the issue?

Zuzanna Wojcik

unread,
Dec 16, 2022, 7:06:40 AM12/16/22
to lavaan
Same problem here, I have the latest version of the package. 
aa<-compareFit(fit.config, fit.metric)
summary(aa)


Length   Class    Mode
      1 FitDiff      S4 

Any ideas?
Thanks.

cla...@googlemail.com

unread,
Jul 10, 2023, 7:02:45 AM7/10/23
to lavaan

But its only a crafty work around that does not allow me to use the full advantage of compareFit() and summary() together.

I highly appreciate any help.

Best

Claudia
Reply all
Reply to author
Forward
0 new messages