Skip to content

Lavaan Package - How to Extract Residuals in Data Values

1 message · Ed Merkle

#
Dear Emily,

The lavaan package is typically used to fit models with latent 
variables, and these models are typically fit to the covariance matrix 
(and not necessarily to the raw data).  Thus, it is usually not 
straightforward to get data residuals from the fitted models. In your 
case, it appears that all variables are observed, so you could use 
"meanstructure=TRUE" within the sem() command to get the intercept for 
your regression.  Then I believe the residuals could be obtained manually.

I also wonder whether your specified model is really what you want. I 
believe that, if you estimate error in all your variables and also 
specify some covariances between independent variables, the model will 
be unidentified.  It appears that you are handling this by fixing b1 to 
be zero, but then you are effectively excluding LOG_SR_A_D from the 
model.  I wonder whether you can get by with a simple regression model 
as estimated by lm().

Ed