Convergence problems in lavaan utility functions but not in model summary

1,941 views
Skip to first unread message

Ruben Arslan

unread,
Nov 8, 2012, 11:22:58 AM11/8/12
to lav...@googlegroups.com
Hey,

with one model I fit I got error messages when using utility functions, but not in the sem() function or
in the model summary. So for one model I got

model3sem <- sem(model=model3, data=mtfs,fixed.x=F,missing="fiml",std.lv=T)
summary(model3sem,fit.measures=T,standardized=T)
## lavaan (0.5-10) converged normally after 1760 iterations
in the model summary and no error message upon fitting it, and 
the converged flag in the "Fit" slot set to true (checked with str() ).

but when I tried to display the modindices I got

head(modificationindices(model3sem)[order(modificationindices(model3sem)$mi,na.last=T,decreasing=T),],12) ## Error: system is computationally singular: reciprocal condition number = ## 6.30392e-21

and when I extracted some coefficients (which worked, except that the fmi was always NA)
parameterEstimates(model3sem, standardized = T)
## Warning: lavaan WARNING: model has NOT converged!

I originally started writing the mail, because I was stumped, but I fixed it by 
dummy-coding two unordered factor variables that I had and decided to send the mail anyway. 
I had seen the warning, but not understood that the unordered factor variables caused problems, I assumed it was a warning applicable to someone who accidentally forgot to specify an ordinal variable. It also worked without problem in some simpler models, but not in my most complex one, so I didn't attribute it to the factor variables.
Maybe especially the warning in parameterEstimates could be corrected or there should be a more obvious warning that unordered factor variables HAVE to be dummy-coded.

Best wishes,

Ruben Arslan

Ruben Arslan

unread,
Nov 8, 2012, 3:06:53 PM11/8/12
to lav...@googlegroups.com
That was apparently a false negative, I again get this problem, so apparently my changes didn't fix it after all.
I was using knitr and it recurred twice. 
How could I narrow this down? Is it something that might happen by chance with some fits and not others?
I attached my session info below. Would the structure of my model help?

Best
Ruben Arslan

## R version 2.15.2 (2012-10-26)
## Platform: i386-apple-darwin9.8.0/i386 (32-bit)
## 
## locale:
## [1] C/en_US.UTF-8/C/C/C/C
## 
## attached base packages:
## [1] splines   stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] reshape2_1.2.1   lubridate_1.2.0  drawSEM_0.1.0-2  qgraph_1.1.0    
##  [5] xtable_1.7-0     psych_1.2.8      lavaan_0.5-10    quadprog_1.5-4  
##  [9] mnormt_1.4-5     car_2.0-15       nnet_7.3-5       stringr_0.6.1   
## [13] QuantPsyc_1.5    MASS_7.3-22      boot_1.3-7       ggplot2_0.9.2.1 
## [17] Hmisc_3.10-1     survival_2.36-14 knitr_0.8       
## 
## loaded via a namespace (and not attached):
##  [1] MplusAutomation_0.5-3 RColorBrewer_1.0-5    cluster_1.14.3       
##  [4] coda_0.15-2           colorspace_1.2-0      dichromat_1.2-4      
##  [7] digest_0.5.2          ellipse_0.3-7         evaluate_0.4.2       
## [10] formatR_0.6           grid_2.15.2           gtable_0.1.1         
## [13] labeling_0.1          lattice_0.20-10       memoise_0.1          
## [16] munsell_0.4           plyr_1.7.1            proto_0.3-9.2        
## [19] relimp_1.0-3          scales_0.2.2          sem_3.0-0            
## [22] stats4_2.15.2         tcltk_2.15.2          tools_2.15.2
--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at http://groups.google.com/group/lavaan?hl=en.
 
 

yrosseel

unread,
Nov 9, 2012, 4:02:27 AM11/9/12
to lav...@googlegroups.com
On 11/08/2012 05:22 PM, Ruben Arslan wrote:
> Hey,
>
> with one model I fit I got error messages when using utility functions,
> but not in the sem() function or
> in the model summary. So for one model I got
>
> model3sem <- sem(model=model3, data=mtfs,fixed.x=F,missing="fiml",std.lv=T)
> summary(model3sem,fit.measures=T,standardized=T)
> ## lavaan (0.5-10) converged normally after 1760 iterations

That is a lot of iterations... must be a trickly model.

> in the model summary and no error message upon fitting it, and
> the converged flag in the "Fit" slot set to true (checked with str() ).

Good. You can also check it as follows:

inspect(fit, "converged")

> but when I tried to display the modindices I got
>
> head(modificationindices(model3sem)[order(modificationindices(model3sem)$mi,na.last=T,decreasing=T),],12)
> ## Error: system is computationally singular: reciprocal condition
> number = ## 6.30392e-21

Hm. It looks like there is numerical instability in the model after all.

> and when I extracted some coefficients (which worked, except that the
> fmi was always NA)
> parameterEstimates(model3sem, standardized=T)
> ## Warning: lavaan WARNING: model has NOT converged!

This warning is related to the fmi for which we need to fit a new model,
and this may fail, especially if the original one was a borderline fit.

> I originally started writing the mail, because I was stumped, but I
> fixed it by
> dummy-coding two unordered factor variables that I had and decided to
> send the mail anyway.
> I had seen the warning, but not understood that the unordered factor
> variables caused problems, I assumed it was a warning applicable to
> someone who accidentally forgot to specify an ordinal variable. It also
> worked without problem in some simpler models, but not in my most
> complex one, so I didn't attribute it to the factor variables.
> Maybe especially the warning in parameterEstimates could be corrected or
> there should be a more obvious warning that unordered factor variables
> HAVE to be dummy-coded.

But this is not what caused the warning.

Yves.

yrosseel

unread,
Nov 9, 2012, 4:03:27 AM11/9/12
to lav...@googlegroups.com
On 11/08/2012 09:06 PM, Ruben Arslan wrote:
> That was apparently a false negative, I again get this problem, so
> apparently my changes didn't fix it after all.
> I was using knitr and it recurred twice.
> How could I narrow this down? Is it something that might happen by
> chance with some fits and not others?
> I attached my session info below. Would the structure of my model help?

Could you send me your R script (and perhaps a snippet of the data) so I
can reproduce this?

Yves.

Reply all
Reply to author
Forward
0 new messages