approximate MI with more than 2 groups

15 views
Skip to first unread message

J S

unread,
Oct 2, 2025, 9:11:51 AM (5 days ago) Oct 2
to blavaan
Hey,

I want to analyze measurement invariance in blavaan for following model: 

workvalue_mod_4<-'
enhan =~ pow_res_1 + stat_5 + stat_6 + ach_adv_4
open  =~ self_act_2 + stim_var_1 + hed_pl_3 + hed_com_2
trans =~ benev_car_8 + equi_acc_3 + equi_adv_8 + sust_env_3
cons  =~ trad_soc_8 + trad_org_1 + conf_inter_5 + conf_form_7
'

Utilizing the wiggle parameter I am able to conduct approximate MI testing for variables contains two groups (e.g. dichotomous gender). However, when I try to analyze approximate MI between variables with >2 groups (e.g. educational levels) I receive following error: 

> # wiggle .05
> bfit4_education1 <- bcfa(model = workvalue_mod_4, data = valuedata_stud4, group = "education_cat1",
+                          group.equal = "loadings", wiggle = "loadings",
+                          wiggle.sd = 0.05, std.lv = TRUE)
Error in rowvec[samppar] <- which(grepl(stanvec[j], names(b.est)) & !(grepl("_c\\[",  :
  replacement has length zero

education_cat1 contains following groups and n's:
Ausbm   HoR   Abi    BA    MA Ausbo
  621  1443   411   521   732  1417

I would appreciate every help I can get! 

Thanks in advance!
Jannick

Ed Merkle

unread,
Oct 2, 2025, 6:17:01 PM (5 days ago) Oct 2
to blavaan
Jannick,

Thanks for the report. Is there any more output that appears between the bcfa() command and the "Error in rowvec" line? If yes, please post it because it might be informative about what is going on.

Ed

J S

unread,
Oct 3, 2025, 3:04:26 AM (4 days ago) Oct 3
to blavaan
Hey Ed,

thanks for your answer, but unfortunately no (see attached as a screenshot). The model without constraints runs perfectly fine (bfit4_education0 <- bcfa(workvalue_mod_4, data = valuedata_stud4, group = "education_cat1", std.lv = TRUE, seed=1108048325)), as does the exact MGCFA approach (fit4_education2<-lavaan::cfa(workvalue_mod_4, data=valuedata_stud4, std.lv=TRUE, estimator="MLR", meanstructure=TRUE, group="education_cat1", group.equal="loadings")) and the grouping variable education_cat1 has no missing values.

Bildschirmfoto 2025-10-03 um 08.59.12.png

Best regards,
Jannick

Ed Merkle

unread,
Oct 3, 2025, 12:24:47 PM (4 days ago) Oct 3
to J S, blavaan
Thanks for following up. It is a little strange because that error typically arises when the Stan sampling does not finish correctly. But then there is usually Stan output before the error. I also tried the wiggle argument on a different 3-group dataset without an error. If you can share the data (even if only with myself off list) and code, that could help me reproduce the error.

I also still suspect there might be more on-screen output than what you are seeing. Maybe your software is gobbling up the extra output and only showing the error message. If you are using Rstudio or Positron or etc, maybe try to run the same model in R outside of those other programs. Then look for more output before the error message.

Ed


On Fri, 2025-10-03 at 00:04 -0700, 'J S' via blavaan wrote:
Hey Ed,

thanks for your answer, but unfortunately no (see attached as a screenshot). The model without constraints runs perfectly fine (bfit4_education0 <- bcfa(workvalue_mod_4, data = valuedata_stud4, group = "education_cat1", std.lv = TRUE, seed=1108048325)), as does the exact MGCFA approach (fit4_education2<-lavaan::cfa(workvalue_mod_4, data=valuedata_stud4, std.lv=TRUE, estimator="MLR", meanstructure=TRUE, group="education_cat1", group.equal="loadings")) and the grouping variable education_cat1 has no missing values.

--
You received this message because you are subscribed to the Google Groups "blavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blavaan+u...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages