semTools::measEq.syntax - Error: no method for coercing this S4 class to a vector

139 views
Skip to first unread message

cla...@googlemail.com

unread,
Apr 4, 2024, 5:37:04 AM4/4/24
to lavaan
Hi,

I am working on measurement invariance analysis using semTools to create syntax for multi-group CFA with categorical indicators (MI across biological sex, 2 groups).

I have been using the very useful measEq.syntax-function until now. However. since beginning of March I cannot execute my syntax anymore.  I have tried a lot of troubleshooting options (see below) - none worked.

Here is example code and exemplary error presentation:
 fit <- measEq.syntax(configural.model = mod.cat, data = df_mi_parent,
                            ordered = c("item1", "item2", "item3", ...., "item25"),
                            group = "sex",group.label=c("1", "2"),
                            estimator ="DWLS",
                            test = "scaled.shifted",
                            se = "robust",
                            parameterization = "theta",
                            ID.fac = "std.lv", ID.cat = "Wu.Estabrook.2016",
                            group.equal = "thresholds")
# Runs perfectly

summary(syntax.thresh)                    # summarize model features
Length Class Mode 1 measEq.syntax S4
mod.thresh <- as.character(syntax.thresh) # save as text
Error in as.character.default(syntax.thresh) : no method for coercing this S4 class to a vector
cat(mod.thresh)  # print/view lavaan syntax
# cannot be executed since line above was aborted.

I have attempted the following troubleshooting approaches. Unfirtunately, all have been  unsuccessful.

1. updated R, lavaan and semTools
3. also tried this, loading semTools (not loading lavaan first etc.): https://github.com/simsem/semTools/issues/116

I would highly appreciate some help on how to overcome the S4 issue. I am not an R-programmer and therefore have a limited understanding of the S3/S4 classesd/objects. I am an applied researcher - Hence, I appreciate any help I solve the issue using semTools or any workaround.

Thanks in advance, I am happy to provide more information or code and hope this follows the community guidelines.

Best

Claudia

Terrence Jorgensen

unread,
Jul 5, 2024, 6:48:44 PM7/5/24
to lavaan
Your example is not complete, so it is difficult to diagnose anything without a full reprex.  Your issues are about an object "syntax.thresh", which is not created in the syntax you posted (instead, an object "fit" is created).

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

 

Reply all
Reply to author
Forward
0 new messages