Multiple-group confirmatory factor analysis - can't find difftest()

262 views
Skip to first unread message

Matti Cervin

unread,
Aug 22, 2018, 3:46:33 AM8/22/18
to lavaan

I am performing a multiple-group confirmatory factor analysis in lavaan for a paper I am working on, guided by this tutorial: https://pareonline.net/pdf/v19n7.pdf.


I work with ordinal indicators and when I try to run the semTools:::difftest(), I get this warning message:


Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : 
object 'difftest' not found


This is the code:


config <- cfa(original_model, estimator="WLSMV",data=mg_cfa_gr_ord, group="identifier",
               ordered = c("o1","o2","o3","o4","o5","o6", "o7", "o8", "o9",
                           "o10","o11","o12","o13","o14","o15","o16","o17",
                           "o18","o19","o20","o21"))

weak <- cfa(original_model, estimator="WLSMV", data=mg_cfa_gr_ord,
             ordered = c("o1","o2","o3","o4","o5","o6", "o7", "o8", "o9",
                         "o10","o11","o12","o13","o14","o15","o16","o17",
                         "o18","o19","o20","o21"),
            group="identifier", group.equal = c("loadings"))

semTools::difftest(config,weak)

Does this mean that the difftest() function is not longer included in the semTools package? Does anyone know which function to use instead?



Terrence Jorgensen

unread,
Aug 25, 2018, 8:04:43 AM8/25/18
to lavaan
Does this mean that the difftest() function is not longer included in the semTools package?

It never was a function offered by the semTools package.  Notice the three colons between semTools and difftest?  That indicates it is a hidden/private function used only internally.  The paper you are using unfortunately was very irresponsible in providing guidance that relied on something that was volatile.  It ceased to exist a few versions ago

Does anyone know which function to use instead?

See the ?lavTestLRT help page.

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

Hui Zhang

unread,
Nov 19, 2018, 1:54:58 AM11/19/18
to lavaan
Hi,

I would like to ask a follow up question; I referred to the same paper that Matti Cervin referred to.  I looked up lavTestLRT and tried to replicate the results in the same paper.

I used this syntax:

lavTestLRT(scs_model_config,scs_model_weak,A.method="delta",type="Chisq")

and would like to ask whether it is correct and if it is, why no AIC or BIC are reported, I got

                 Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)    
scs_model_config 70         1135.1                                  
scs_model_weak   79         1310.9     81.827       9  7.003e-14 ***

The authors of the paper reported delta.cfi.

Thank you!

Terrence Jorgensen

unread,
Nov 23, 2018, 10:53:01 AM11/23/18
to lavaan

lavTestLRT(scs_model_config,scs_model_weak,A.method="delta",type="Chisq")

and would like to ask whether it is correct

What, the syntax? Yes.

and if it is, why no AIC or BIC are reported,

If you used a least-squares estimator (e.g., DWLS for categorical outcomes) instead of a likelihood estimator, then there is no likelihood with which to calculate information criteria.

The authors of the paper reported delta.cfi.

That will not tell you anything useful, but you can find the CFI from each model using fitMeasures(). You can also use the compareFit() function in semTools.

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics


Research Institute for Child Development and Education, the University of Amsterdam

Reply all
Reply to author
Forward
0 new messages