negative covariance

40 views
Skip to first unread message

Aryanne van Delft

unread,
Aug 3, 2018, 5:49:34 AM8/3/18
to lavaan
Hi everyone,

I have a question. My model shows negative covariances for the observed variables but I do not understand why 



WSPISNPBCATTINTHAG <- ' 
# Latent variables
Intention =~ 1*I2 + A8 +  A14
Hagerbaum =~ 1*H1 + H2 + H3 + H4 + H5 + H6
Attitude =~ 1*A1 + A5 + A6
PerceivedBehavioralControl =~ 1*A3 + A10


# Regression
Hagerbaum ~  Intention + PerceivedBehavioralControl
Intention ~ Attitude + PerceivedBehavioralControl + A9 + SS + JD + WJI + WTC 
'

# Run Lavaan
MODELWSPISNPBCATTINTHAG <- sem(model = WSPISNPBCATTINTHAG, data=mydata, orthogonal=FALSE, std.lv=TRUE)
summary(MODELWSPISNPBCATTINTHAG, fit.measures=TRUE, standardized=TRUE)

#covariantiematrix
lavInspect(MODELWSPISNPBCATTINTHAG, "h1")

inspect(MODELWSPISNPBCATTINTHAG,"cor.all",) 
inspect(MODELWSPISNPBCATTINTHAG, "rsquare")








lavaan (0.6-1) converged normally after  36 iterations

  Number of observations                           219

  Estimator                                         ML
  Model Fit Test Statistic                     260.131
  Degrees of freedom                               141
  P-value (Chi-square)                           0.000

Model test baseline model:

  Minimum Function Test Statistic             1607.013
  Degrees of freedom                               161
  P-value                                        0.000

User model versus baseline model:

  Comparative Fit Index (CFI)                    0.918
  Tucker-Lewis Index (TLI)                       0.906

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -5092.353
  Loglikelihood unrestricted model (H1)      -4962.288

  Number of free parameters                         34
  Akaike (AIC)                               10252.706
  Bayesian (BIC)                             10367.935
  Sample-size adjusted Bayesian (BIC)        10260.190

Root Mean Square Error of Approximation:

  RMSEA                                          0.062
  90 Percent Confidence Interval          0.050  0.074
  P-value RMSEA <= 0.05                          0.048

Standardized Root Mean Square Residual:

  SRMR                                           0.085

Parameter Estimates:

  Information                                 Expected
  Information saturated (h1) model          Structured
  Standard Errors                             Standard

Latent Variables:
                                Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Intention =~                                                                       
    I2                             1.000                               1.895    0.697
    A8                             0.782    0.064   12.245    0.000    1.482    0.866
    A14                            0.666    0.063   10.518    0.000    1.262    0.723
  Hagerbaum =~                                                                       
    H1                             1.000                               1.176    0.882
    H2                             0.486    0.053    9.210    0.000    0.572    0.559
    H3                             0.912    0.056   16.385    0.000    1.073    0.804
    H4                             1.082    0.050   21.679    0.000    1.273    0.909
    H5                             0.766    0.070   10.913    0.000    0.901    0.632
    H6                             1.027    0.054   19.084    0.000    1.207    0.862
  Attitude =~                                                                        
    A1                             1.000                               1.000    0.534
    A5                             1.339    0.143    9.389    0.000    1.339    0.651
    A6                             1.011    0.109    9.281    0.000    1.011    0.644
  PerceivedBehavioralControl =~                                                      
    A3                             1.000                               1.000    0.509
    A10                            1.688    0.149   11.364    0.000    1.688    0.914

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Hagerbaum ~                                                           
    Intention         0.397    0.070    5.662    0.000    0.640    0.640
    PrcvdBhvrlCntr   -0.234    0.128   -1.833    0.067   -0.199   -0.199
  Intention ~                                                           
    Attitude          1.094    0.229    4.768    0.000    0.577    0.577
    PrcvdBhvrlCntr    0.564    0.204    2.762    0.006    0.298    0.298
    A9                0.120    0.048    2.477    0.013    0.063    0.139
    SS               -0.039    0.021   -1.851    0.064   -0.021   -0.106
    JD                0.017    0.041    0.417    0.676    0.009    0.026
    WJI               0.014    0.055    0.250    0.803    0.007    0.014
    WTC              -0.083    0.045   -1.859    0.063   -0.044   -0.119

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Attitude ~~                                                           
    PrcvdBhvrlCntr    0.660    0.073    8.994    0.000    0.660    0.660

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .I2                3.803    0.420    9.055    0.000    3.803    0.514
   .A8                0.732    0.127    5.755    0.000    0.732    0.250
   .A14               1.452    0.166    8.727    0.000    1.452    0.477
   .H1                0.394    0.050    7.852    0.000    0.394    0.222
   .H2                0.720    0.071   10.132    0.000    0.720    0.688
   .H3                0.631    0.069    9.107    0.000    0.631    0.354
   .H4                0.340    0.050    6.860    0.000    0.340    0.174
   .H5                1.222    0.122    9.978    0.000    1.222    0.601
   .H6                0.503    0.061    8.273    0.000    0.503    0.256
   .A1                2.500    0.266    9.414    0.000    2.500    0.714
   .A5                2.438    0.307    7.942    0.000    2.438    0.576
   .A6                1.442    0.179    8.035    0.000    1.442    0.585
   .A3                2.859    0.299    9.569    0.000    2.859    0.741
   .A10               0.560    0.368    1.520    0.129    0.560    0.164
   .Intention         1.000                               0.278    0.278
   .Hagerbaum         1.000                               0.723    0.723
    Attitude          1.000                               1.000    1.000
    PrcvdBhvrlCntr    1.000                               1.000    1.000

Terrence Jorgensen

unread,
Aug 3, 2018, 8:17:34 AM8/3/18
to lavaan
My model shows negative covariances for the observed variables but I do not understand why

Your model only estimates one covariance, and it is between latent, not observed, variables.

 Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Attitude ~~                                                           
    PrcvdBhvrlCntr    0.660    0.073    8.994    0.000    0.660    0.660
 
Are you referring to the model-implied correlations?

inspect(MODELWSPISNPBCATTINTHAG,"cor.all")

I don't see why that would be a problem.  Are the observed covariances not negative for the same observed-variable pairs?

lavInspect(MODELWSPISNPBCATTINTHAG, "sampstat")

You can see how much the model-implied values differ from the observed values:

resid(MODELWSPISNPBCATTINTHAG)

In a correlation metric:

resid(MODELWSPISNPBCATTINTHAG, type = "cor")

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

Aryanne van Delft

unread,
Aug 6, 2018, 9:22:55 AM8/6/18
to lavaan





On Friday, August 3, 2018 at 2:17:34 PM UTC+2, Terrence Jorgensen wrote:
My model shows negative covariances for the observed variables but I do not understand why

Your model only estimates one covariance, and it is between latent, not observed, variables.
I thought that estimating covariances is the default setting of lavaan? When I draw a path digram via semPaths(MODELWSPISNPBCATTINTHAG, "model", "standardized estimates"), negative covariances are presented. 


I don't see why that would be a problem.  Are the observed covariances not negative for the same observed-variable pairs? 
Some of the covariances are negative  

lavInspect(MODELWSPISNPBCATTINTHAG, "sampstat")

You can see how much the model-implied values differ from the observed values:

resid(MODELWSPISNPBCATTINTHAG)

In a correlation metric:

resid(MODELWSPISNPBCATTINTHAG, type = "cor")

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


lavInspect(MODELWSPISNPBCATTINTHAG, "sampstat")
resid(MODELWSPISNPBCATTINTHAG)
resid(MODELWSPISNPBCATTINTHAG, type = "cor") 


> lavInspect(MODELWSPISNPBCATTINTHAG, "sampstat")
$`cov`
    I2     A8     A14    H1     H2     H3     H4     H5     H6     A1     A5     A6     A3     A10    A9     SS     JD     WJI    WTC   
I2   7.461                                                                                                                              
A8   2.893  2.955                                                                                                                       
A14  2.631  1.800  3.065                                                                                                                
H1   1.400  0.948  0.701  1.381                                                                                                         
H2   0.609  0.582  0.474  0.512  0.994                                                                                                  
H3   1.256  0.795  0.711  0.914  0.667  1.599                                                                                           
H4   1.503  1.036  0.838  1.174  0.596  1.157  1.703                                                                                    
H5   1.272  0.775  0.672  0.743  0.462  0.879  0.920  1.904                                                                             
H6   1.374  0.734  0.719  1.128  0.484  1.087  1.286  1.004  1.728                                                                      
A1   1.449  0.917  0.733  0.360  0.201  0.293  0.216  0.352  0.342  3.239                                                               
A5   1.600  1.507  1.376  0.377  0.329  0.471  0.499  0.515  0.395  1.425  4.190                                                        
A6   1.445  1.295  1.224  0.373  0.305  0.323  0.567  0.522  0.405  0.633  1.280  2.442                                                 
A3   0.831  1.162  0.889  0.366  0.186 -0.061  0.379 -0.061 -0.008  0.696  1.341  1.007  4.236                                          
A10  1.773  1.828  1.587  0.601  0.278  0.300  0.575  0.335  0.361  0.838  1.460  1.203  2.071  3.518                                   
A9   0.998  1.110  1.229  0.487  0.408  0.475  0.510  0.684  0.739  0.305  0.735  0.829 -0.344  0.696  4.809                            
SS  -1.967 -0.840  0.417 -0.728 -0.605 -1.083 -1.333 -0.191 -1.063  0.319  1.109  0.182  1.338  0.274 -0.758 26.366                     
JD   0.962  0.636  0.820  0.439  0.148  0.482  0.904  0.889  0.796 -0.054  0.764  0.375 -0.745  0.024  1.956 -2.171  8.527              
WJI  0.324 -0.067 -0.276  0.086  0.168  0.180  0.134  0.051  0.199 -0.346 -0.711 -0.391 -0.387 -0.087  0.362 -3.674 -0.326  3.742       
WTC -0.752 -0.460 -0.340 -0.327 -0.110 -0.427 -0.680 -0.462 -0.692  0.138 -0.008  0.440  1.325  0.534 -1.913  3.496 -4.209 -0.679  7.379

$mean
    I2     A8    A14     H1     H2     H3     H4     H5     H6     A1     A5     A6     A3    A10     A9     SS     JD    WJI    WTC 
 6.982  6.868  6.799  3.128  1.566  2.242  2.785  2.370  2.717  3.580  6.621  7.365  4.744  6.082  5.868 33.553 12.425  5.219 11.557 

> resid(MODELWSPISNPBCATTINTHAG)
$`type`
[1] "raw"

$cov
    I2     A8     A14    H1     H2     H3     H4     H5     H6     A1     A5     A6     A3     A10    A9     SS     JD     WJI    WTC   
I2   0.067                                                                                                                              
A8   0.084  0.027                                                                                                                       
A14  0.239 -0.070  0.020                                                                                                                
H1   0.273  0.068 -0.049 -0.395                                                                                                         
H2   0.061  0.154  0.110 -0.160 -0.052                                                                                                  
H3   0.228 -0.009  0.026 -0.347  0.053 -0.183                                                                                           
H4   0.284  0.082  0.026 -0.323 -0.131 -0.208 -0.258                                                                                    
H5   0.409  0.100  0.098 -0.316 -0.053 -0.088 -0.227 -0.129                                                                             
H6   0.217 -0.170 -0.051 -0.292 -0.206 -0.208 -0.250 -0.083 -0.232                                                                      
A1  -0.017 -0.230 -0.244 -0.069 -0.007 -0.097 -0.248  0.024 -0.098 -0.261                                                               
A5  -0.362 -0.028  0.069 -0.196  0.050 -0.052 -0.122  0.075 -0.194  0.087 -0.040                                                        
A6  -0.038  0.135  0.236 -0.060  0.094 -0.073  0.098  0.191 -0.040 -0.378 -0.074 -0.023                                                 
A3  -0.455  0.157  0.033  0.089  0.051 -0.314  0.079 -0.273 -0.293  0.037  0.459  0.340  0.377                                          
A10 -0.398  0.131  0.142  0.133  0.050 -0.127  0.068 -0.023 -0.119 -0.275 -0.030  0.077  0.383  0.110                                   
A9   0.194  0.482  0.694  0.168  0.253  0.184  0.165  0.439  0.411  0.305  0.735  0.829 -0.344  0.696  0.000                            
SS  -0.464  0.335  1.418 -0.131 -0.315 -0.539 -0.687  0.267 -0.450  0.319  1.109  0.182  1.338  0.274  0.000  0.000                     
JD   0.152  0.003  0.281  0.117 -0.009  0.188  0.556  0.642  0.466 -0.054  0.764  0.375 -0.745  0.024  0.000  0.000  0.000              
WJI  0.033 -0.294 -0.469 -0.029  0.112  0.075  0.009 -0.037  0.081 -0.346 -0.711 -0.391 -0.387 -0.087  0.000  0.000  0.000  0.000       
WTC  0.308  0.369  0.366  0.095  0.095 -0.043 -0.223 -0.139 -0.259  0.138 -0.008  0.440  1.325  0.534  0.000  0.000  0.000  0.000  0.000

$mean
 I2  A8 A14  H1  H2  H3  H4  H5  H6  A1  A5  A6  A3 A10  A9  SS  JD WJI WTC 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 

> resid(MODELWSPISNPBCATTINTHAG, type = "cor")
$`type`
[1] "cor.bollen"

$cor
    I2     A8     A14    H1     H2     H3     H4     H5     H6     A1     A5     A6     A3     A10    A9     SS     JD     WJI    WTC   
I2   0.000                                                                                                                              
A8   0.012  0.000                                                                                                                       
A14  0.046 -0.028  0.000                                                                                                                
H1   0.125  0.083  0.018  0.000                                                                                                         
H2   0.027  0.095  0.068 -0.056  0.000                                                                                                  
H3   0.080  0.014  0.027 -0.094  0.080  0.000                                                                                           
H4   0.101  0.064  0.035 -0.037 -0.050 -0.029  0.000                                                                                    
H5   0.115  0.050  0.048 -0.099 -0.017 -0.004 -0.063  0.000                                                                             
H6   0.079 -0.053 -0.003 -0.031 -0.112 -0.039 -0.034  0.009  0.000                                                                      
A1   0.007 -0.062 -0.066 -0.002  0.003 -0.028 -0.085  0.019 -0.023  0.000                                                               
A5  -0.065 -0.008  0.020 -0.052  0.029 -0.009 -0.029  0.032 -0.058  0.039  0.000                                                        
A6  -0.009  0.050  0.087 -0.004  0.064 -0.025  0.065  0.094 -0.005 -0.119 -0.019  0.000                                                 
A3  -0.093  0.029 -0.003  0.045  0.024 -0.120  0.032 -0.097 -0.107  0.008  0.100  0.097  0.000                                          
A10 -0.086  0.030  0.035  0.083  0.028 -0.047  0.039 -0.007 -0.039 -0.074 -0.012  0.022  0.071  0.000                                   
A9   0.032  0.127  0.180  0.080  0.117  0.072  0.066  0.148  0.149  0.077  0.164  0.242 -0.076  0.169  0.000                            
SS  -0.033  0.039  0.158 -0.033 -0.063 -0.087 -0.109  0.036 -0.072  0.035  0.106  0.023  0.127  0.028  0.000  0.000                     
JD   0.019  0.000  0.055  0.045 -0.002  0.055  0.152  0.161  0.127 -0.010  0.128  0.082 -0.124  0.004  0.000  0.000  0.000              
WJI  0.006 -0.089 -0.139 -0.007  0.059  0.033  0.007 -0.013  0.035 -0.099 -0.180 -0.129 -0.097 -0.024  0.000  0.000  0.000  0.000       
WTC  0.042  0.080  0.077  0.014  0.033 -0.018 -0.072 -0.040 -0.080  0.028 -0.001  0.104  0.237  0.105  0.000  0.000  0.000  0.000  0.000

$mean
 I2  A8 A14  H1  H2  H3  H4  H5  H6  A1  A5  A6  A3 A10  A9  SS  JD WJI WTC 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 



Terrence Jorgensen

unread,
Aug 7, 2018, 8:14:51 AM8/7/18
to lavaan
I thought that estimating covariances is the default setting of lavaan?

Only among exogenous latent variables, of which you only have 2.

 Some of the covariances are negative  

Then it sounds like there is nothing wrong with expecting the model-implied covariances to be negative too.  If your model fits well, it should reproduce your observed sample statistics.

Aryanne van Delft

unread,
Aug 8, 2018, 8:29:15 AM8/8/18
to lavaan
Thanks a lot !!!
Reply all
Reply to author
Forward
0 new messages