lavaan error: covariance matrix of the residuals of the observed variables is not positive definite

1,124 views
Skip to first unread message

Emma Mills

unread,
Dec 17, 2016, 2:23:37 PM12/17/16
to lavaan

Hi 

I am carry out a mediation structural model and have received the below warning. What does this mean and how can I correct this? Full syntax is attached.


Thanks very much!



> SCTModel2 <- '

+ RBehF1=~BF1_RAV+BF2_RAV+BF3_RAV+BF4_RAV+BF6_RAV+BF7_RAV

+ RJobSat=~RaterJobSat

+ RReward=~RaterReward

+ # direct effect

+ RaterJobSat ~ c*RBehF1

+ # mediator

+ RaterReward ~ a*RBehF1

+ RaterJobSat ~ b*RaterReward

+ # indirect effect (a*b)

+ indirect := a*b

+ # total effect

+ total := c + (a*b)

+ RBehF1~~RaterJobSat

+ RBehF1~~RaterReward

+ RaterReward~~RaterJobSat

+ '

>

> SCT1fit2<-sem(SCTModel2, data = SMBI_Alldata, test = "bollen.stine",  se="boot", bootstrap = 5000)

Warning message:

In lav_object_post_check(lavobject) :

  lavaan WARNING: the covariance matrix of the residuals of the observed

                variables (theta) is not positive definite;

                use inspect(fit,"theta") to investigate.

 

 

inspect(SCT1fit2,"theta") 
            BF1_RA BF2_RA BF3_RA BF4_RA BF6_RA BF7_RA RtrJbS RtrRwr
BF1_RAV     0.038                                                  
BF2_RAV     0.000  0.029                                           
BF3_RAV     0.000  0.000  0.030                                    
BF4_RAV     0.000  0.000  0.000  0.041                             
BF6_RAV     0.000  0.000  0.000  0.000  0.026                      
BF7_RAV     0.000  0.000  0.000  0.000  0.000  0.040               
RaterJobSat 0.000  0.000  0.000  0.000  0.000  0.000  0.000        
RaterReward 0.000  0.000  0.000  0.000  0.000  0.000  0.117  0.000 

 

 

Mediation_17.12.16.docx

Terrence Jorgensen

unread,
Dec 17, 2016, 6:59:34 PM12/17/16
to lavaan

What does this mean and how can I correct this?


You can find out what an NPD matrix is with a quick Google search.  Here is a quite informative page:


It doesn't necessarily need "correction", if sampling variability is a better explanation than model misspecification.  Concluding so requires (a) your model fits well and (b) the 95% CI for the Heywood case includes plausible values. Here is an article on the topic:


But in your specific case, I would guess the problem is that you are modeling the relationship between RaterJobSat and RaterReward twice (as a regression path "b" and as a residual covariance), which is a particularly odd choice because you are using them as single indicators of latent constructs:

RJobSat=~RaterJobSat

RReward=~RaterReward

RaterJobSat ~ b*RaterReward

RaterReward~~RaterJobSat


I'm surprised lavaan even converged on a solution, because this model is not identified.  Regardless, your theta matrix is NPD because it is impossible for two variables (here, "residuals" of RaterJobSat and RaterReward) to covary (i.e., to vary together) when they don't even vary.

            RtrJbS RtrRwr

RaterJobSat  0.000        
RaterReward  0.117  0.000 

If there is a regression between those variables, then there is no need to additionally estimate a correlation between their residuals (likewise for both of those with RBehF1).  And if you are using them as single indicators, then you should estimate the regression path between the latent variables, not between the indicators.

SCTModel2 <- '
  RBehF1 =~ BF1_RAV + BF2_RAV + BF3_RAV + BF4_RAV + BF6_RAV + BF7_RAV
  RJobSat =~ RaterJobSat
  RReward =~ RaterReward
# direct effect
  RJobSat ~ c*RBehF1
# mediator
  RReward ~ a*RBehF1
  RJobSat ~ b*RReward 
# indirect effect (a*b)
  indirect := a*b
# total effect
  total := c + (a*b)
'

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


Camille Williams

unread,
Feb 25, 2019, 5:24:57 AM2/25/19
to lavaan
Hi Terrence Jorgensen,

How do we determine "(b) the 95% CI for the Heywood case includes plausible values."? Is it located in the summary of our model ?
Best, 

Camille Williams 

Terrence Jorgensen

unread,
Feb 28, 2019, 10:10:37 PM2/28/19
to lavaan
How do we determine "(b) the 95% CI for the Heywood case includes plausible values."? Is it located in the summary of our model ?

yes, that is an option

summary(fit, ci=TRUE)


Or you can use the parameterEstimates() function.

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam
Reply all
Reply to author
Forward
0 new messages