SAM and ESEM : Error in information + crossprod(H)

48 views
Skip to first unread message

Nathan Pudles

unread,
Jan 19, 2026, 10:42:08 AMJan 19
to lavaan
Hi,

I'm trying to fit a model with SAM within the ESEM framework, which returns the following error message:
Error in information + crossprod(H) : non-conformable arrays

I'm using lavaan version  0.6.21.2434.

Here's an example using the data of study 1 from Marsh and Alamer (2024) 

> model <- ' ##Measurement #Block 1 efa("teacher")*Teacher_autonomy + efa("teacher")*Teacher_competence + efa("teacher")*Teacher_relatedness =~ T_autonomy1 + T_autonomy2 + T_autonomy3 + T_competence1 + T_competence2 + T_competence3 + T_relatedness1 + T_relatedness2 + T_relatedness3
#Block 2
efa("self")*Self_Meaning + efa("self")*Self_Confidence + efa("self")*Intrinsic_Motivation =~ S_meaning1 + S_meaning2 + S_meaning3 + S_confidence1 + S_confidence2 + S_confidence3 + S_Intrinsic1 + S_Intrinsic2 + S_Intrinsic3 #Block 3 Intent_to_Quit =~ Intent_to_withdraw1 + Intent_to_withdraw2 + Intent_to_withdraw3 + Intent_to_withdraw4 + Intent_to_withdraw5 ##Structural part Self_Meaning ~ Teacher_autonomy + Teacher_competence + Teacher_relatedness Self_Confidence ~ Teacher_autonomy + Teacher_competence + Teacher_relatedness Intrinsic_Motivation ~ Teacher_autonomy + Teacher_competence + Teacher_relatedness Intent_to_Quit ~ Self_Meaning + Self_Confidence + Intrinsic_Motivation + Teacher_autonomy + Teacher_competence + Teacher_relatedness '

sam_res <- sam(model = model, data = data_ex, mm.list = list(teacher = c("Teacher_autonomy", "Teacher_competence", "Teacher_relatedness"), self = c("Self_Meaning", "Self_Confidence", "Intrinsic_Motivation"), Quit = "Intent_to_Quit"), mm.args = list(estimator = "MLR"), struc.args = list(estimator = "ML"), sam.method = "local", std.lv = TRUE, rotation = "geomin", rotation.args = list(geomin.epsilon = 0.001), output = "lavaan")
Error in information + crossprod(H) : non-conformable arrays

Best regards,

Nathan

Felipe Vieira

unread,
Jan 19, 2026, 10:56:19 AMJan 19
to lav...@googlegroups.com
Hi,

Just by looking at the error message, I think it is related to a small bug that was fixed a few months ago. Try a newer version of lavaan. 

If that doesn't work, I will look into it more carefully. 

Best, 
Felipe. 

--
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 visit https://groups.google.com/d/msgid/lavaan/a7d3530b-ea8e-418b-8e8d-2add9089476dn%40googlegroups.com.

Felipe Vieira

unread,
Jan 19, 2026, 11:26:20 AMJan 19
to lav...@googlegroups.com
Hi, 

In the end, I checked it, and I was wrong. It seems to be a bug that creates a dimension mismatch. 

I will try to fix it or file an issue on GitHub. 

Best, 
Felipe. 


Felipe Vieira

unread,
Jan 22, 2026, 11:27:27 AMJan 22
to lav...@googlegroups.com
Hi, 

This is now fixed on GitHub. If anyone ever tries this again, let me know if something goes wrong 

Best, 
Felipe.

Nathan Pudles

unread,
Jan 29, 2026, 5:08:41 AM (14 days ago) Jan 29
to lav...@googlegroups.com
Hi,

Thank you for your quick response. The model can now be estimated. However, when estimating set-ESEM with sam(), the covariances of the factors in an ESEM block seem to be constrained to be equal, within and across ESEM blocks. These covariance are not representative of the covariances of the same factors found when fitting the model with sem().  This happens with every structural model estimator. This is not the case when fitting the model with only CFA blocks; the covariances are freely estimated. I'm guessing this constraint would contribute to explain the drop in fit indices of the structural part when comparing the model fitted with sam() within the ESEM framework vs the CFA framework.

I'm now using lavaan version 0.6-22.2484.

Using the same data and model as the example from my first message (Marsh & Alamer, 2024):

##Set-ESEM with sam() : 
sam_esem_res <- sam(model = model,
                data = data_ex,
                mm.list = list(teacher = c("Teacher_autonomy", "Teacher_competence", "Teacher_relatedness"),
                               self = c("Self_Meaning", "Self_Confidence", "Intrinsic_Motivation"),
                               Quit = "Intent_to_Quit"),
                mm.args = list(estimator = "MLR"),
                struc.args = list(estimator = "ML"),
                sam.method = "local",
                std.lv = TRUE,
                rotation = "geomin",
                rotation.args = list(geomin.epsilon = 0.001),
                output = "lavaan")

lavInspect(sam_esem_res, what = "est")$psi
                     Tchr_t Tchr_c Tchr_r Slf_Mn Slf_Cn Intr_M Int__Q
Teacher_autonomy      0.715                                          
Teacher_competence    0.385  0.884                                   
Teacher_relatedness   0.385  0.385  0.772                            
Self_Meaning          0.000  0.000  0.000  1.164                     
Self_Confidence       0.000  0.000  0.000  0.385  1.082              
Intrinsic_Motivation  0.000  0.000  0.000  0.385  0.385  0.661       
Intent_to_Quit        0.000  0.000  0.000  0.000  0.000  0.000  0.598

Summary Information Structural part: chisq df cfi rmsea srmr 94.131 5 0.802 0.257 0.185
##Set-ESEM with sem(): sem_esem_res <- sem(model = model, data = data_ex, estimator = "MLR",
                     std.lv = TRUE,
                     rotation = "geomin",
                     rotation.args = list(geomin.epsilon = 0.001))
lavInspect(sem_esem_res, what = "est")$psi Tchr_t Tchr_c Tchr_r Slf_Mn Slf_Cn Intr_M Int__Q Teacher_autonomy 1.000 Teacher_competence 0.741 1.000 Teacher_relatedness 0.664 0.598 1.000 Self_Meaning 0.000 0.000 0.000 1.000 Self_Confidence 0.000 0.000 0.000 0.173 1.000 Intrinsic_Motivation 0.000 0.000 0.000 0.070 0.266 1.000 Intent_to_Quit 0.000 0.000 0.000 0.000 0.000 0.000 1.000

##CFA with sam():
model_cfa <- '
 ##Measurement
 #Block 1
 Teacher_autonomy =~ T_autonomy1 + T_autonomy2 + T_autonomy3
 Teacher_competence =~ T_competence1 + T_competence2 + T_competence3
 Teacher_relatedness =~ T_relatedness1 + T_relatedness2 + T_relatedness3
 
 #Block 2
 Self_Meaning =~ S_meaning1 + S_meaning2 + S_meaning3
 Self_Confidence =~ S_confidence1 + S_confidence2 + S_confidence3
 Intrinsic_Motivation =~ S_Intrinsic1 + S_Intrinsic2 + S_Intrinsic3
 
 #Block 3
 Intent_to_Quit =~ Intent_to_withdraw1 + Intent_to_withdraw2 + Intent_to_withdraw3 + Intent_to_withdraw4 + Intent_to_withdraw5
 
 ##Structural part
 Self_Meaning ~ Teacher_autonomy + Teacher_competence + Teacher_relatedness
 
 Self_Confidence ~ Teacher_autonomy + Teacher_competence + Teacher_relatedness
 
 Intrinsic_Motivation ~ Teacher_autonomy + Teacher_competence + Teacher_relatedness
 
 Intent_to_Quit ~ Self_Meaning + Self_Confidence + Intrinsic_Motivation + 
                  Teacher_autonomy + Teacher_competence + Teacher_relatedness

 ##Covariance between block 2 factors
 Self_Meaning ~~ Self_Confidence + Intrinsic_Motivation
 Self_Confidence ~~ Intrinsic_Motivation
 '
sam_cfa_res <- sam(model = model_cfa,
                data = data_ex,
                mm.list = list(teacher = c("Teacher_autonomy", "Teacher_competence", "Teacher_relatedness"),
                               self = c("Self_Meaning", "Self_Confidence", "Intrinsic_Motivation"),
                               Quit = "Intent_to_Quit"),
                mm.args = list(estimator = "MLR"),
                struc.args = list(estimator = "ML"),
                sam.method = "local",
                std.lv = TRUE,
                output = "lavaan")
lavInspect(sam_cfa_res, what = "est")$psi Tchr_t Tchr_c Tchr_r Slf_Mn Slf_Cn Intr_M Int__Q Teacher_autonomy 1.000 Teacher_competence 0.764 1.000 Teacher_relatedness 0.794 0.655 1.000 Self_Meaning 0.000 0.000 0.000 0.837 Self_Confidence 0.000 0.000 0.000 0.201 0.892 Intrinsic_Motivation 0.000 0.000 0.000 0.054 0.200 0.411 Intent_to_Quit 0.000 0.000 0.000 0.000 0.000 0.000 0.588 Summary Information Structural part: chisq df cfi rmsea srmr 0 0 1 0 0 Moreover, when fitting multigroup set-ESEM with sam(), the error message mentioned in my first post returns again. Example : sam_res <- sam(model = struct, data = df_treat, mm.list = list(ML = c("f1","f2","f3","f4"), #ESEM block FWC = "FWC"), #Outcome mm.args = list(estimator = "MLR", rotation = "geomin", rotation.args = list(geomin.epsilon = 0.001)),
             struc.args = list(estimator = "ML"),
             group = "D01",                               #grouping variable (2 categories)
             sam.method = "local",
             output = "lavaan",
             std.lv = TRUE)



Best regards,

Nathan




Reply all
Reply to author
Forward
0 new messages