Error in Summary() function for a fitted sem.mi object

170 views
Skip to first unread message

Brandon McCormick

unread,
Jun 2, 2020, 6:44:53 PM6/2/20
to lavaan
Before I talk about my error, I wanted to thank everyone (mostly Terrence) for being so helpful with my inquiries lately. 

That said, I think I have the final inquiry for the large model I have been working on. 

My model seems to converge normally, but when I call the summary() function I receive this error. 

Error in dimnames(W) <- dimnames(B) : 'dimnames' applied to non-array

Here is my code: 

fitmTBI_Off_Med2 <- sem.mi(mTBI_Off_Med2 , data = mTBI_SEM_Data_Imps)
summary(fitmTBI_Off_Med2 , standardized=TRUE, fit.measures=TRUE, ci=TRUE)


Here is my model if that is relevant:

mTBI_Off_Med2 <- '
  
#Wave 1 LV’s 
  
# IM_W1 
  
IM_W1 =~ NA* IM1_W1 + IM2_W1 + IM3_W1 + IM4_W1 + IM5_W1

IM_W1 ~~ 1* IM_W1

IM1_W1 ~~ IM2_W1
IM2_W1 ~~ IM5_W1
IM3_W1 ~~ IM5_W1

#AD_W1  

AD_W1 =~ NA* AD1_W1 + AD2_W1 + AD3_W1 + AD4_W1 + AD5_W1 + AD6_W1 + AD7 _W1 + AD8_W1 + AD9 _W1 + AD10_W1 + AD11_W1 + AD12_W1 + AD13_W1 + AD14_W1

AD_W1 ~~ 1* AD_W1

AD1_W1 ~~  AD2_W1 + AD6_W1 + AD7_W1 + AD11_W1
AD3_W1 ~~  AD4_W1 + AD7_W1 + AD8_W1 + AD10_W1 + AD14_W1 
AD4_W1 ~~ AD9_W1
AD5_W1 ~~  AD2_W1 + AD4_W1 
AD6_W1 ~~  AD7_W1
AD8_W1 ~~ AD4_W1 + AD5_W1 + AD9_W1 + AD10_W1
AD11_W1 ~~ AD12_W1
AD10_W1 ~~ AD9_W1 + AD12_W1 + AD13_W1
AD13_W1 ~~ AD4_W1 + AD12_W1

ASB_CUT_W1 =~ NA* CU1_W1 + CU2_W1 + CU3_W1 + CU4_W1 + ASB1_W1 + ASB2_W1 + ASB3_W1 + ASB4_W1 + ASB5_W1 + ASB6_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W2 ~~  ASB9_W2
ASB6_W2 ~~ ASB3_W2 +  ASB7_W2 + ASB8_W2 + ASB10_W2
ASB7_W2 ~~ ASB3_W2 + ASB4_W2 + ASB3_W2 + ASB10_W2 

#based on MI

IM1_W2 ~~   IM3_W2 + IM2_W2 + ASB2_W2 
IM2_W2 ~~   AD3_W2 + AD10_W2 + AD14_W2
IM3_W2 ~~ AD4_W2
IM4_W2 ~~   AD3_W2 + AD4_W2 + AD6_W2 + ASB6_W2 
IM5_W2 ~~   IM3_W2 + AD5_W2
ASB2_W2 ~~  ASB5_W2
ASB3_W2 ~~  AD3_W2  + AD9_W2 
AD3_W2 ~~  CU2_W2
AD7_W2 ~~  AD8_W2 + CU1_W2
AD12_W2 ~~  ASB9_W2
AD14_W2 ~~ AD11_W2 + ASB2_W2 + ASB8_W2
ASB7_W2 ~~ AD4_W2 + AD5_W2 + AD7_W2 + AD8_W2

#correlate LV’s W2

IM_W2 ~~ c* AD_W2 + ASB_CUT_W2
AD_W2 ~~ ASB_CUT_W2

#correlate LV’s W1

IM_W1 ~~ c* AD_W1 + ASB_CUT_W1
AD_W1 ~~ ASB_CUT_W1

#Regression paths 
#direct effects

NVtot_log ~ C1 *  HI_Bi_B21 
VOtot_log ~ C2 * HI_Bi_B21 

#Mediation: A paths

IM_W2 ~ A1 * HI_Bi_B21 
AD_W2 ~ A2 * HI_Bi_B21 
ASB_CUT_W2 ~ A3*  HI_Bi_B21 

#Mediation: B paths

NVtot_log ~ B1_1 * IM_W2
NVtot_log ~ B2_1 * AD_W2
NVtot_log ~ B3_1 * ASB_CUT_W2 

VOtot_log ~ B1_2 * IM_W2
VOtot_log ~ B2_2 * AD_W2
VOtot_log ~ B3_2 * ASB_CUT_W2 

#Effect estimates

indirect1_1 := A1 * B1_1
indirect2_1 := A2 * B2_1
indirect3_1 := A3 * B3_1

indirect1_2 := A1 * B1_2
indirect2_2 := A2 * B2_2
indirect3_2 := A3 * B3_2

total1_1 := C1 + (A1 * B1_1)
total2_1 := C1 + (A2 * B2_1)
total3_1 := C1 + (A3 * B3_1)

total1_2 := C2 + (A1 * B1_2)
total2_2 := C2 + (A2 * B2_2)
total3_2 := C2 + (A3 * B3_2)

#control paths: W1 LV’s

IM_W2 ~ IM_W1
AD_W2 ~ AD_W1
ASB_CUT_W2 ~ ASB_CUT_W1

NVtot_log ~ IM_W1 + AD_W1 + ASB_CUT_W1
VOtot_log ~ IM_W1 + AD_W1 + ASB_CUT_W1

#control paths: other vars

IM_W2 ~ Age_W3 + Sex + Ethnicity + Neighborhood_SES + PC_EDU
AD_W2 ~ Age_W3 + Sex + Ethnicity + Neighborhood_SES + PC_EDU
ASB_CUT_W2 ~ Age_W3 + Sex + Ethnicity + Neighborhood_SES + PC_EDU

NVtot_log ~ Age_W3 + Sex + Ethnicity + Neighborhood_SES + PC_EDU
VOtot_log ~ Age_W3 + Sex + Ethnicity + Neighborhood_SES + PC_EDU'

Brandon McCormick

unread,
Jun 2, 2020, 9:31:45 PM6/2/20
to lav...@googlegroups.com
Weirdly enough, I restarted Rstudio and tried again. 

Now when I use the summary(fit) function, 

I get this output:

avaanList (0.6-6) -- based on 40 datasets (40 converged)

Latent Variables:
                    est.ave
  IM_W1 =~                
    IM1_W1            0.377
    IM2_W1            0.424
    IM3_W1            0.384
    IM4_W1            0.273
    IM5_W1            0.422
  AD_W1 =~                
    AD1_W1            0.347
    AD2_W1            0.239
    AD3_W1            0.211
    AD4_W1            0.227
    AD5_W1            0.204
    AD6_W1            0.200
    AD7_W1            0.194
    AD8_W1            0.305
    AD9_W1            0.218
    AD10_W1           0.181
    AD11_W1           0.154
    AD12_W1           0.301
    AD13_W1           0.271
    AD14_W1           0.238
(this was shortened)

If I try to add additional arguments: summary(fitmTBI_Off_Med2 , standardized=TRUE, fit.measures=TRUE, ci=TRUE), I get the error:

Error in .local(object, ...) :
  unused arguments (standardized = TRUE, fit.measures = TRUE, ci = TRUE)

--
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/e734e3aa-3b29-4382-ac82-d0c210409c4b%40googlegroups.com.


--

Brandon McCormick

Doctoral Student

Clinical Psychology - Psychology and Law 
The University of Alabama
101 McMillan
Tuscaloosa, AL 35401 
Phone 205-460-8678
b.mccorm...@gmail.com

The University of Alabama stacked logo with box A

Brandon McCormick

unread,
Jun 3, 2020, 1:25:22 PM6/3/20
to lavaan
I tried the summary function with a similar model that previously had no problems displaying, but now I am getting the same error. Is anyone else having this problem?

Terrence Jorgensen

unread,
Jun 4, 2020, 6:27:22 PM6/4/20
to lavaan
Does sessionInfo() output verify you are using lavaan 0.6-6 and semTools 0.5-3?  When you restart RStudio, does running sessionInfo() show that you have packages (other than the base packages) attached?  RStudio has pain-in-the-ass default settings to automatically save your workspace, which can interfere with expected performance. 

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

Wendy Lau

unread,
Jul 29, 2021, 6:31:15 PM7/29/21
to lavaan

I am experiencing the same problem.... did anyone find out what was wrong?
i am using semTools_0.5-5  lavaan_0.6-9
thanks

Terrence Jorgensen

unread,
Jul 30, 2021, 5:06:41 AM7/30/21
to lavaan
Does your sessionInfo() show that the VGAM package is loaded?  That problem will eventually be resolved:


Otherwise, without a minimal reproducible example (data + R script), I can't simply guess what your issue really is (or even assume it is actually the same issue, since the original poster did not respond here again).
Reply all
Reply to author
Forward
0 new messages