Running RI-CLPM with semTools auxiliary: residuals of the observed variables (theta) is not positive definite;

174 views
Skip to first unread message

Atanas Janackovski

unread,
Sep 15, 2021, 6:04:15 PM9/15/21
to lavaan
I am running an RI-CLPM and using the semTools::auxilary function with additional covariates to help model estimate the missing data under MAR and FIML estimation. However, I am getting the error: 'residuals of the observed variables (theta) is not positive definite'. This seems to be in one of the covariates / auxiliary variables. See below for specification and relevant output.

Can someone please give guidance on where I should go with this error? I have listed the categorical variables and also tried to apply the "theta" parameterization, but still getting this warning.

Thanks in advance.

--------

aux_vars <-
  c("ac_1", "age", "sex_mf", "cov_sess", "hxdsh", "hxtrauma")

riclpm_sat_aux2 <-
  lavaan.auxiliary(
    riclpm_sat_mod,
    aux = aux_vars,
    data = phd_fin_wide,
    missing = "ML",
    estimator = "MLR",
    meanstructure = TRUE,
    int.ov.free = TRUE,
    bounds = TRUE,
    ordered = c("sex_mf", "hxdsh", "hxtrauma"),
    parameterization = "theta"
  )




> lavInspect(riclpm_sat_aux2, "post.check")
[1] FALSE
Warning message:
In lav_object_post_check(object) :
  lavaan WARNING: the covariance matrix of the residuals of the observed
                variables (theta) is not positive definite;
                use lavInspect(fit, "theta") to investigate.
> lavInspect(riclpm_sat_aux2, "theta")
         pb_1   pb_2   pb_3   pb_4   pb_5   tb_1   tb_2   tb_3   tb_4   tb_5   bhs_1  bhs_2  bhs_3  bhs_4  bhs_5  dep_1  dep_2  dep_3  dep_4  dep_5  si_1   si_2   si_3   si_4   si_5   ac_1   age    sex_mf cv_sss hxdsh  hxtram
pb_1      0.000                                                                                                                                                                                                                  
pb_2      0.000  0.000                                                                                                                                                                                                           
pb_3      0.000  0.000  0.000                                                                                                                                                                                                    
pb_4      0.000  0.000  0.000  0.000                                                                                                                                                                                             
pb_5      0.000  0.000  0.000  0.000  0.000                                                                                                                                                                                      
tb_1      0.000  0.000  0.000  0.000  0.000  0.000                                                                                                                                                                               
tb_2      0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                                                                                                        
tb_3      0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                                                                                                 
tb_4      0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                                                                                          
tb_5      0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                                                                                   
bhs_1     0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                                                                            
bhs_2     0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                                                                     
bhs_3     0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                                                              
bhs_4     0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                                                       
bhs_5     0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                                                
dep_1     0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                                         
dep_2     0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                                  
dep_3     0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                           
dep_4     0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                    
dep_5     0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                             
si_1      0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                      
si_2      0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                               
si_3      0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                        
si_4      0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                 
si_5      0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                          
ac_1     14.747 16.279 12.361 14.449 13.089  9.364  9.006  6.567  8.525  8.432  9.392 10.200  8.585  7.948  8.907  6.616  8.404  5.743  7.499  7.774 13.082  8.643  5.289  5.998  8.525 41.959                                   
age      -1.304 -2.489 -1.267 -1.636 -2.268  3.423  2.247  3.681  3.132  1.024 -0.028  0.200  0.287 -0.154  0.220  1.607  0.941  1.922  1.999  1.137  1.803  1.258  1.179  1.444 -0.046 -1.891  8.975                            
sex_mf   -0.537 -0.525 -0.490 -0.565 -0.684 -0.185 -0.325 -0.216 -0.385 -0.567 -0.133 -0.070 -0.110 -0.120 -0.274 -0.078 -0.118 -0.159 -0.228 -0.302 -0.148  0.062  0.282 -0.111 -0.191  0.079  0.282  0.206                     
cov_sess  1.148  3.324  5.754  7.513  8.249  1.425  3.602  4.442  6.465  6.608  1.460  2.255  3.106  3.603  4.581  0.941  2.018  2.907  4.138  4.950  2.290  3.347  3.939  5.005  4.208  0.987 -0.740 -0.097  4.651              
hxdsh     0.948  0.706  0.447  0.630  0.571  0.722  0.870  0.984  0.977  0.920  0.342  0.339  0.374  0.348  0.532  0.306  0.260  0.262  0.431  0.445  0.534  0.345  0.101  0.329  0.149  0.376  0.104 -0.050 -0.003  0.208       
hxtrauma  0.585  0.520  0.590  0.470  0.388  0.380  0.336  0.539  0.500  0.309  0.146  0.080  0.257  0.065  0.132  0.227  0.211  0.370  0.252  0.233  0.228  0.533  0.361  0.562  0.212  0.194  0.144 -0.035 -0.045  0.072  0.246
>

Ulrich Schroeders

unread,
Sep 16, 2021, 2:46:02 AM9/16/21
to lavaan
Dear Atanas,

1. You have to add fixed.x = FALSE (see ?auxiliary).
2. Auxiliary can't be ordered.

I'm not sure if this tackles your model issues.

Kind regards
Ulrich

Atanas Janackovski

unread,
Sep 17, 2021, 8:11:16 AM9/17/21
to lavaan
Thanks Ulrich… Always read the docs!

However, this did not solve my problem. I found a post with a similar issues here: https://groups.google.com/g/lavaan/c/ihYCsLW5528

Terrence Jorgensen wrote in the linked post: "… your theta matrix is NPD because it is impossible for two variables (here, "residuals" … to covary (i.e., to vary together) when they don't even vary." I am new to SEM so do not fully understand what is happening, but I've posted my model syntax as well as the warning. Sorry for all the syntax and output. I think maybe this is because I've contrained the observed varaibles and latent variables (e.g., '1*pb_1). I followed the model syntax from Mulder and Hamaker (2021).

Any suggestions if I need to do anything to correct this?

Mulder, J. D., & Hamaker, E. L. (2021). Three Extensions of the Random Intercept Cross-Lagged Panel Model. Structural Equation Modeling: A Multidisciplinary Journal, 28(4), 638–648. doi: 10/ghjkz9


riclpm_sat_mod <- '
  ## Create between components (random intercepts)
  RIpb  =~ 1*pb_1 + 1*pb_2 + 1*pb_3 + 1*pb_4 + 1*pb_5
  RItb  =~ 1*tb_1 + 1*tb_2 + 1*tb_3 + 1*tb_4 + 1*tb_5
  RIbhs =~ 1*bhs_1 + 1*bhs_2 + 1*bhs_3 + 1*bhs_4 + 1*bhs_5
  RIdep =~ 1*dep_1 + 1*dep_2 + 1*dep_3 + 1*dep_4 + 1*dep_5
  RIsi  =~ 1*si_1 + 1*si_2 + 1*si_3 + 1*si_4 + 1*si_5
  ## =======
  ## Create within-person centered variables
  wpb_1 =~ 1*pb_1
  wpb_2 =~ 1*pb_2
  wpb_3 =~ 1*pb_3
  wpb_4 =~ 1*pb_4
  wpb_5 =~ 1*pb_5
  ## ==
  wtb_1 =~ 1*tb_1
  wtb_2 =~ 1*tb_2
  wtb_3 =~ 1*tb_3
  wtb_4 =~ 1*tb_4
  wtb_5 =~ 1*tb_5
  ## ==
  wbhs_1 =~ 1*bhs_1
  wbhs_2 =~ 1*bhs_2
  wbhs_3 =~ 1*bhs_3
  wbhs_4 =~ 1*bhs_4
  wbhs_5 =~ 1*bhs_5
  ## ==
  wdep_1 =~ 1*dep_1
  wdep_2 =~ 1*dep_2
  wdep_3 =~ 1*dep_3
  wdep_4 =~ 1*dep_4
  wdep_5 =~ 1*dep_5
  ## ==
  wsi_1 =~ 1*si_1
  wsi_2 =~ 1*si_2
  wsi_3 =~ 1*si_3
  wsi_4 =~ 1*si_4
  wsi_5 =~ 1*si_5
  ## =====
  ##
  ## Estimate the lagged effects between the within-person centered variables.
  wpb_2 + wtb_2 + wbhs_2 + wdep_2 + wsi_2 ~ wpb_1 + wtb_1 + wbhs_1 + wdep_1 + wsi_1 # nolint
  wpb_3 + wtb_3 + wbhs_3 + wdep_3 + wsi_3 ~ wpb_2 + wtb_2 + wbhs_2 + wdep_2 + wsi_2 # nolint
  wpb_4 + wtb_4 + wbhs_4 + wdep_4 + wsi_4 ~ wpb_3 + wtb_3 + wbhs_3 + wdep_3 + wsi_3 # nolint
  wpb_5 + wtb_5 + wbhs_5 + wdep_5 + wsi_5 ~ wpb_4 + wtb_4 + wbhs_4 + wdep_4 + wsi_4 # nolint
  ## ==
  ## Estimate the covariance between the within-person centered variables
  ## at the first wave.
  wpb_1  ~~ wtb_1 # Covariance
  wpb_1  ~~ wbhs_1
  wpb_1  ~~ wdep_1
  wpb_1  ~~ wsi_1
  wtb_1  ~~ wbhs_1
  wtb_1  ~~ wdep_1
  wtb_1  ~~ wsi_1
  wbhs_1 ~~ wsi_1
  wbhs_1 ~~ wdep_1
  wdep_1 ~~ wsi_1
  ## Estimate the covariances between the residuals of the within-person
  ## centered variables (the innovations).
  ## time_2
  wpb_2  ~~ wtb_2
  wpb_2  ~~ wbhs_2
  wpb_2  ~~ wdep_2
  wpb_2  ~~ wsi_2
  wtb_2  ~~ wbhs_2
  wtb_2  ~~ wdep_2
  wtb_2  ~~ wsi_2
  wbhs_2 ~~ wsi_2
  wbhs_2 ~~ wdep_2
  wdep_2 ~~ wsi_2
  ## time_3
  wpb_3  ~~ wtb_3
  wpb_3  ~~ wbhs_3
  wpb_3  ~~ wdep_3
  wpb_3  ~~ wsi_3
  wtb_3  ~~ wbhs_3
  wtb_3  ~~ wdep_3
  wtb_3  ~~ wsi_3
  wbhs_3 ~~ wsi_3
  wbhs_3 ~~ wdep_3
  wdep_3 ~~ wsi_3
  ## time_4
  wpb_4  ~~ wtb_4
  wpb_4  ~~ wbhs_4
  wpb_4  ~~ wdep_4
  wpb_4  ~~ wsi_4
  wtb_4  ~~ wbhs_4
  wtb_4  ~~ wdep_4
  wtb_4  ~~ wsi_4
  wbhs_4 ~~ wsi_4
  wbhs_4 ~~ wdep_4
  wdep_4 ~~ wsi_4
  ## time_5
  wpb_5  ~~ wtb_5
  wpb_5  ~~ wbhs_5
  wpb_5  ~~ wdep_5
  wpb_5  ~~ wsi_5
  wtb_5  ~~ wbhs_5
  wtb_5  ~~ wdep_5
  wtb_5  ~~ wsi_5
  wbhs_5 ~~ wsi_5
  wbhs_5 ~~ wdep_5
  wdep_5 ~~ wsi_5
  ## Estimate the variance and covariance of the random intercepts.
  RIpb  ~~ RIpb
  RItb  ~~ RItb
  RIbhs ~~ RIbhs
  RIdep ~~ RIdep
  RIsi  ~~ RIsi
  ## ==
  RIpb  ~~ RItb
  RIpb  ~~ RIbhs
  RIpb  ~~ RIdep
  RIpb  ~~ RIsi
  RItb  ~~ RIbhs
  RItb  ~~ RIdep
  RItb  ~~ RIsi
  RIbhs ~~ RIsi
  RIbhs ~~ RIdep
  RIdep ~~ RIsi
  ## Estimate the (residual) variance of the within-person centered variables.
  wpb_1  ~~ wpb_1 # Variances
  wtb_1  ~~ wtb_1
  wbhs_1 ~~ wbhs_1
  wdep_1 ~~ wdep_1
  wsi_1  ~~ wsi_1
  ## time_2
  wpb_2  ~~ wpb_2 # Residual variances
  wtb_2  ~~ wtb_2
  wbhs_2 ~~ wbhs_2
  wdep_2 ~~ wdep_2
  wsi_2  ~~ wsi_2
  ## time_3
  wpb_3  ~~ wpb_3 # Residual variances
  wtb_3  ~~ wtb_3
  wbhs_3 ~~ wbhs_3
  wdep_3 ~~ wdep_3
  wsi_3  ~~ wsi_3
  ## time_4
  wpb_4  ~~ wpb_4 # Residual variances
  wtb_4  ~~ wtb_4
  wbhs_4 ~~ wbhs_4
  wdep_4 ~~ wdep_4
  wsi_4  ~~ wsi_4
  ## time_5
  wpb_5  ~~ wpb_5 # Residual variances
  wtb_5  ~~ wtb_5
  wbhs_5 ~~ wbhs_5
  wdep_5 ~~ wdep_5
  wsi_5  ~~ wsi_5
'


> lavInspect(riclpm_sat_aux, "theta")

            pb_1   pb_2   pb_3   pb_4   pb_5   tb_1   tb_2   tb_3   tb_4   tb_5   bhs_1  bhs_2  bhs_3  bhs_4  bhs_5  dep_1  dep_2  dep_3  dep_4  dep_5  si_1 

pb_1         0.000                                                                                                                                            

pb_2         0.000  0.000                                                                                                                                    

pb_3         0.000  0.000  0.000                                                                                                                              

pb_4         0.000  0.000  0.000  0.000                                                                                                                       

pb_5         0.000  0.000  0.000  0.000  0.000                                                                                                               

tb_1         0.000  0.000  0.000  0.000  0.000  0.000                                                                                                         

tb_2         0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                                 

tb_3         0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                          

tb_4         0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                                    

tb_5         0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                            

bhs_1        0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                                     

bhs_2        0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                               

bhs_3        0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                       

bhs_4        0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                                

bhs_5        0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                         

dep_1        0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                                  

dep_2        0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                           

dep_3        0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000                    

dep_4        0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000             

dep_5        0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000      

si_1         0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000

si_2         0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000

si_3         0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000

si_4         0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000

si_5         0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000  0.000

ac_1        14.756 16.274 12.363 14.434 13.135  9.362  9.022  6.540  8.538  8.422  9.382 10.205  8.572  7.904  8.885  6.595  8.409  5.737  7.483  7.713 13.041

age         -1.332 -2.501 -1.277 -1.690 -2.253  3.389  2.252  3.679  3.097  0.922 -0.044  0.203  0.298 -0.247  0.102  1.607  0.946  1.905  1.989  1.048  1.842

sex_mf      -0.540 -0.524 -0.489 -0.566 -0.672 -0.182 -0.332 -0.218 -0.388 -0.572 -0.134 -0.073 -0.111 -0.117 -0.284 -0.078 -0.119 -0.161 -0.230 -0.315 -0.144

ses_int_log -0.181 -0.172 -0.205 -0.169 -0.253 -0.056 -0.202 -0.171 -0.134 -0.078 -0.051 -0.085 -0.103  0.023  0.002 -0.057 -0.071 -0.033 -0.067 -0.022 -0.298

cov_sess     1.201  3.346  5.755  7.596  8.216  1.469  3.611  4.420  6.525  6.780  1.468  2.270  3.072  3.811  4.831  0.952  2.031  3.008  4.225  5.122  2.287

hxdsh        0.945  0.699  0.444  0.631  0.561  0.718  0.879  0.984  0.977  0.931  0.340  0.340  0.374  0.357  0.548  0.305  0.261  0.259  0.432  0.458  0.535

hxtrauma     0.577  0.516  0.587  0.457  0.379  0.373  0.333  0.537  0.490  0.292  0.144  0.080  0.256  0.045  0.115  0.225  0.212  0.365  0.247  0.225  0.221

            si_2   si_3   si_4   si_5   ac_1   age    sex_mf ss_nt_ cv_sss hxdsh  hxtram

pb_1                                                                                    

pb_2                                                                                   

pb_3                                                                                   

pb_4                                                                                    

pb_5                                                                                   

tb_1                                                                                   

tb_2                                                                                    

tb_3                                                                                   

tb_4                                                                                   

tb_5                                                                                    

bhs_1                                                                                  

bhs_2                                                                                  

bhs_3                                                                                  

bhs_4                                                                                  

bhs_5                                                                                   

dep_1                                                                                  

dep_2                                                                                  

dep_3                                                                                   

dep_4                                                                                  

dep_5                                                                                  

si_1                                                                                    

si_2         0.000                                                                     

si_3         0.000  0.000                                                              

si_4         0.000  0.000  0.000                                                        

si_5         0.000  0.000  0.000  0.000                                                

ac_1         8.672  5.266  5.929  8.280 41.951                                         

age          1.293  1.204  1.426 -0.156 -1.896  8.973                                  

sex_mf       0.065  0.282 -0.111 -0.215  0.078  0.283  0.206                            

ses_int_log -0.151 -0.164 -0.122  0.002 -0.022 -0.002  0.007  0.036                    

cov_sess     3.314  3.893  5.041  4.449  0.992 -0.736 -0.097 -0.085  4.649             

hxdsh        0.341  0.104  0.329  0.162  0.377  0.103 -0.050 -0.001 -0.003  0.208      

hxtrauma     0.536  0.365  0.559  0.197  0.192  0.142 -0.035  0.001 -0.045  0.072  0.246

> 

Terrence Jorgensen

unread,
Sep 17, 2021, 9:02:17 AM9/17/21
to lavaan
You are correlating auxiliaries with residuals of variables that have 0 residual variance because they are treated as single-indicator factors to enter the model.  I don't think you need to worry about this warning message, but if you want to investigate further (e.g., to see if it is really NPD, which still might be nothing to worry about), then you have to manually incorporate the auxiliaries into your syntax by correlating them with the single-indicator factors (which have variance) rather than the observed counterparts (whose variances are restricted to zero so that all variance is represented in the factor)

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

Atanas Janackovski

unread,
Sep 17, 2021, 9:25:10 AM9/17/21
to lav...@googlegroups.com
Thanks so much Terence. Just to be sure, I would run this via the regular lavaan function and not the semTools wrapper?

--
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/kr0JWacZLT8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/292fd536-c028-4112-a206-7bea252792b4n%40googlegroups.com.

Atanas Janackovski

unread,
Sep 17, 2021, 9:45:28 AM9/17/21
to lavaan
I have added the below to the syntax to incorporate the auxiliary variables into the model, however not sure that I have done this correctly as I am getting the error. Any guidance on what I may be doing wrong would be greatly appreciated. Thanks again.

Error in solve.default(H, A) :
  Lapack routine dgesv: system is exactly singular: U[1,1] = 0
In addition: Warning messages:
1: In lav_data_full(data = data, group = group, cluster = cluster,  :
  lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate
2: In lavaan(riclpm_cov_mod, data = phd_fin_wide, missing = "ML", estimator = "MLR",  :
  lavaan WARNING:
    Model estimation FAILED! Returning starting values.


  wpb_1 + wpb_2 + wpb_3 + wpb_4 + wpb_5 ~~ ac_1 + age + sex_mf + ses_int_log + cov_sess + hxdsh + hxtrauma
  wtb_1 + wtb_2 + wtb_3 + wtb_4 + wtb_5 ~~ ac_1 + age + sex_mf + ses_int_log + cov_sess + hxdsh + hxtrauma
  wbhs_1 + wbhs_2 + wbhs_3 + wbhs_4 + wbhs_5 ~~ ac_1 + age + sex_mf + ses_int_log + cov_sess + hxdsh + hxtrauma
  wdep_1 + wdep_2 + wdep_3 + wdep_4 + wdep_5 ~~ ac_1 + age + sex_mf + ses_int_log + cov_sess + hxdsh + hxtrauma
  wsi_1 + wsi_2 + wsi_3 + wsi_4 + wsi_5 ~~ ac_1 + age + sex_mf + ses_int_log + cov_sess + hxdsh + hxtrauma

Atanas Janackovski

unread,
Sep 17, 2021, 4:20:41 PM9/17/21
to lav...@googlegroups.com
Should I also model the covariates as time invariant predictors of the factor scores like one would do on a linear regression model on addition to correlating them?

Atanas Janackovski

unread,
Sep 17, 2021, 4:56:33 PM9/17/21
to lav...@googlegroups.com
Actually, I found this link that gives an example in a growth model which I think should help:

Atanas Janackovski

unread,
Sep 17, 2021, 8:06:27 PM9/17/21
to lavaan
Okay, so I ran the model with the covariates incorporated into the model syntax and I do get an error re: the covariance matrix of the latent variables is not positive definite.  Is this something I should be worried about?



+ Warning messages:

1: In lav_data_full(data = data, group = group, cluster = cluster,  :
  lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate
2: In lav_object_post_check(object) :
  lavaan WARNING: covariance matrix of latent variables
                is not positive definite;
                use lavInspect(fit, "cov.lv") to investigate.

> lavaan::lavInspect(riclpm_cov_fit, "cov.lv")
       RIpb     RItb     RIbhs    RIdep    RIsi     wpb_1    wpb_2    wpb_3    wpb_4    wpb_5    wtb_1    wtb_2   
RIpb    377.105                                                                                                   
RItb    259.188  355.364                                                                                          
RIbhs   217.274  133.198  170.321                                                                                 
RIdep   143.798  260.068   40.780  355.569                                                                        
RIsi    138.832   46.889   45.759  138.965  350.969                                                               
wpb_1  -183.312 -139.161 -114.872  -88.681  -80.715   69.921                                                      
wpb_2  -170.349 -127.711 -106.680  -79.350  -75.612   38.420   49.657                                             
wpb_3  -158.866 -119.073  -97.246  -70.926  -71.735   12.905   16.428   31.474                                    
wpb_4  -146.326 -108.624  -91.606  -62.129  -60.275    1.713    2.294    1.610   18.646                           
wpb_5  -150.086 -111.661  -92.323  -64.221  -62.752    1.969    2.587    3.070    6.347   32.634                  
wtb_1  -123.008 -161.380  -63.973 -132.990  -23.451   39.977   25.637    9.436    1.385    1.466   53.341         
wtb_2  -112.494 -150.125  -58.440 -125.746  -19.364   25.951   32.147   17.072    2.923    2.782   22.863   54.077
wtb_3  -101.032 -139.976  -50.493 -116.137  -16.621   11.284   14.841   19.525    4.779    3.491   10.142   22.877
wtb_4   -94.410 -133.733  -47.112 -112.784  -13.928    4.697    6.098    9.574   13.839    7.978    3.952    8.693
wtb_5   -96.292 -138.136  -48.593 -115.603  -10.685    4.529    5.953    7.274    6.851   14.526    3.357    6.269
wbhs_1 -108.009  -66.190  -83.345  -25.686  -27.197   24.692   20.122    6.465    0.986    1.084   17.439   13.870
wbhs_2  -98.278  -58.383  -77.120  -20.658  -23.168   12.757   18.701    6.846    1.234    1.304    8.665   16.386
wbhs_3  -95.272  -56.369  -74.539  -17.619  -21.146    7.859   10.437   10.445    2.783    2.498    5.802   11.097
wbhs_4  -93.755  -55.883  -74.237  -15.985  -18.734    5.383    7.094    8.103   10.402    6.312    3.950    7.263
wbhs_5  -90.743  -53.734  -72.882  -15.800  -16.723    3.024    3.987    4.475    5.207    8.723    2.167    3.854
wdep_1  -63.110 -131.283  -17.950 -179.698  -70.028   30.633   20.518    7.262    0.962    1.137   22.550   15.039
wdep_2  -54.017 -122.347  -13.156 -172.927  -65.876   20.119   24.521    9.775    1.145    1.503   13.465   19.558
wdep_3  -46.518 -116.373   -7.812 -167.279  -64.073    6.784    8.833   13.958    0.119    1.507    4.956    9.226
wdep_4  -41.124 -111.762   -5.659 -164.253  -58.689    3.294    4.311    5.355    7.453    4.266    2.208    3.632
wdep_5  -39.392 -111.547   -5.052 -164.867  -57.513    2.117    2.775    3.459    2.867   11.125    1.484    2.584
wsi_1   -53.663  -15.170  -17.474  -67.539 -162.634   23.385   19.452    7.324    0.779    1.086   13.327   10.338
wsi_2   -50.179  -15.543  -13.872  -65.433 -160.409    9.768   14.761   10.727    0.462    1.140    5.074    9.527
wsi_3   -52.740  -17.584  -13.681  -64.942 -161.977    5.285    6.497   19.199    1.020    1.628    4.449   10.670
wsi_4   -49.335  -12.419  -11.662  -63.469 -166.270    2.240    2.811    5.998    3.586    4.304    1.630    3.184
wsi_5   -53.354  -15.849  -15.357  -66.436 -168.333    1.515    1.925    3.858   -2.314    3.279    1.174    2.381
       wtb_3    wtb_4    wtb_5    wbhs_1   wbhs_2   wbhs_3   wbhs_4   wbhs_5   wdep_1   wdep_2   wdep_3   wdep_4  
RIpb                                                                                                              
RItb                                                                                                              
RIbhs                                                                                                             
RIdep                                                                                                             
RIsi                                                                                                              
wpb_1                                                                                                             
wpb_2                                                                                                             
wpb_3                                                                                                             
wpb_4                                                                                                             
wpb_5                                                                                                             
wtb_1                                                                                                             
wtb_2                                                                                                             
wtb_3    50.267                                                                                                   
wtb_4    15.917   39.272                                                                                          
wtb_5     7.980   15.158   38.374                                                                                 
wbhs_1    5.423    2.359    2.457   17.537                                                                        
wbhs_2    5.130    2.563    2.887    8.594   13.415                                                               
wbhs_3   13.434    6.144    5.415    4.462    5.636   11.484                                                      
wbhs_4    8.793   14.952   12.211    2.960    3.521    6.500   15.459                                             
wbhs_5    4.083    7.031   12.481    1.680    2.023    3.603    8.291   12.750                                    
wdep_1    5.152    2.452    2.579   14.301    8.214    4.646    3.093    1.767   23.760                           
wdep_2    3.982    2.750    3.358   10.909   11.652    6.282    4.063    2.384   12.511   18.933                  
wdep_3   11.252    5.516    4.354    3.522    4.046    7.717    4.547    2.552    3.867    5.219   12.668         
wdep_4    1.694   10.336    7.171    1.880    2.383    3.957    8.040    4.951    2.060    3.080    2.852   11.200
wdep_5    2.264    5.891   12.718    1.176    1.433    2.483    5.073    8.096    1.265    1.781    2.000    4.729
wsi_1     3.355    2.024    2.491   10.671    9.244    4.517    2.998    1.757   14.940   11.783    4.012    2.205
wsi_2     4.415    2.845    2.756    3.869    6.558    4.458    3.129    1.813    5.789   10.290    5.697    2.374
wsi_3    16.824   13.093    3.035    2.456    2.837    7.735    2.041    0.553    3.068    4.430   12.751    1.750
wsi_4     2.747    9.271    1.139    1.188    1.458    2.638    3.996    1.218    1.401    2.154    1.742    3.988
wsi_5     3.346    5.858    5.976    0.755    0.829    1.625    1.994    3.073    0.851    1.133    1.937    0.176
       wdep_5   wsi_1    wsi_2    wsi_3    wsi_4    wsi_5   
RIpb                                                        
RItb                                                        
RIbhs                                                       
RIdep                                                       
RIsi                                                        
wpb_1                                                       
wpb_2                                                       
wpb_3                                                       
wpb_4                                                       
wpb_5                                                       
wtb_1                                                       
wtb_2                                                       
wtb_3                                                       
wtb_4                                                       
wtb_5                                                       
wbhs_1                                                      
wbhs_2                                                      
wbhs_3                                                      
wbhs_4                                                      
wbhs_5                                                      
wdep_1                                                      
wdep_2                                                      
wdep_3                                                      
wdep_4                                                      
wdep_5   13.325                                             
wsi_1     1.301   64.819                                    
wsi_2     1.433   13.404   37.737                           
wsi_3     1.133    2.988    6.394   44.646                  
wsi_4     1.542    1.442    2.062    8.404   41.526         
wsi_5     2.891    0.819    1.276    4.721   14.670   32.516
>


Terrence Jorgensen

unread,
Sep 18, 2021, 2:51:35 AM9/18/21
to lavaan
the covariance matrix of the latent variables is not positive definite.  Is this something I should be worried about?

Not sure.  I don't see any negative variances, but you requested the marginal covariance matrix, not residual.  

lavInspect(riclpm_cov_fit, "est")$psi # actual estimates

You could check the correlation matrix for values > 1

any(lavInspect(riclpm_cov_fit, "cor.lv") > 1)  # marginal
any(lavInspect(riclpm_cov_fit, "est")$psi > 1) # residual

If there are no specific Heywood cases, then it is a case of linear dependency in the residual covariance matrix, which can be hard to track down the source of.  But if your determinant or smallest eigenvalue are nearly zero (only a little negative, way out in the decimal places), then I wouldn't worry about it.

Just to check you implemented the saturated correlates approach as described in the Enders citation (see References on the ?auxiliary help page), does this model have the same df as the model without any auxiliaries?  To address an earlier question, the point is to not change the substantive interpretation of your model or its df, by allowing each auxiliary to correlate with each observed variable's residual (which you put in the latent space) and with other auxiliaries. 

Atanas Janackovski

unread,
Sep 18, 2021, 8:14:32 AM9/18/21
to lavaan
Sorry about that… This is all new to me, so I truly appreciate the patience and help. Okay, so I think I have updated the syntax as per the Enders' citation,  because my above syntax was clearly wrong… I have included the syntax further below, and now I'm not getting any warnings apart from the below, which I hope I don't have to worry about.

lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate

The added syntax is:

  ## ==========
  ## cov variances
  ## ==========
  ac_1 ~~ ac_1
  age ~~ age
  sex_mf ~~ sex_mf
  cov_sess ~~ cov_sess
  hxdsh ~~ hxdsh
  hxtrauma ~~ hxtrauma
  ses_int_log ~~ ses_int_log
  ## ==========
  ## cov covariances
  ## ==========
  ac_1 ~~ age + sex_mf + cov_sess + hxdsh + hxtrauma + ses_int_log
  age ~~ sex_mf + cov_sess + hxdsh + hxtrauma + ses_int_log
  sex_mf ~~ cov_sess + hxdsh + hxtrauma + ses_int_log
  cov_sess ~~ hxdsh + hxtrauma + ses_int_log
  hxdsh ~~ hxtrauma + ses_int_log
  hxtrauma ~~ ses_int_log
  ## ==========
  ## cov covs
  ## ==========
  wpb_1 + wpb_2 + wpb_3 + wpb_4 + wpb_5 ~~ ac_1 + age + sex_mf + ses_int_log + cov_sess + hxdsh + hxtrauma # nolint
  wtb_1 + wtb_2 + wtb_3 + wtb_4 + wtb_5 ~~ ac_1 + age + sex_mf + ses_int_log + cov_sess + hxdsh + hxtrauma # nolint
  wbhs_1 + wbhs_2 + wbhs_3 + wbhs_4 + wbhs_5 ~~ ac_1 + age + sex_mf + ses_int_log + cov_sess + hxdsh + hxtrauma # nolint
  wdep_1 + wdep_2 + wdep_3 + wdep_4 + wdep_5 ~~ ac_1 + age + sex_mf + ses_int_log + cov_sess + hxdsh + hxtrauma # nolint
  wsi_1 + wsi_2 + wsi_3 + wsi_4 + wsi_5 ~~ ac_1 + age + sex_mf + ses_int_log + cov_sess + hxdsh + hxtrauma # nolint

I'm getting very similar estimates to the semTools wrapper, and the model has the same dfs. I think I understand this now… The only questions I have is when bringing the aux vars into the model, should they be constrained so that they are the same for each variable over multiple time points? e.g.

wpb_1 + wpb_2 + wpb_3 + wpb_4 + wpb_5 ~~ s1*ac_1 + s2*age + s3*sex_mf + s4*ses_int_log + s5*cov_sess + hxdsh + hxtrauma # nolint

Thanks again,

Atanas

Terrence Jorgensen

unread,
Oct 4, 2021, 3:47:48 AM10/4/21
to lavaan
The only questions I have is when bringing the aux vars into the model, should they be constrained so that they are the same for each variable over multiple time points? e.g.

With constraints, the correlates would no longer be saturated.  I don't think it is necessary to do this, and is sort of at odds with the idea that these are auxiliary variables about which we have no hypotheses except that they can relate to missing values.  Allowing their coefficients to vary over time is essentially moderation by time, which can't be ruled out.
Reply all
Reply to author
Forward
0 new messages