Hello R Community,
I am using the Lavaan package in R 2.15.0 to analyze data collected from
1200 lakes across North America. My dataset includes 3 continuous
independent variables (LOG_NTL, LOG_PTL, and LOG_SR_A_D) and 1 continuous
dependent variable (BIOVOL) . I have successfully constructed structural
equation models using the Lavaan package (example included below with
code), but I have not been able to figure out how to extract the
residuals in the data values themselves (the unexplained values) of my
dependent variable, BIOVOL. For the last step of my analysis, I would like
to plot the residuals for BIOVOL against one of the independent variables
to see the relationship. I understand how to get the residuals for the
covariance matrix, but I do not know how to get the residuals in the data
values themselves for BIOVOL. Does anyone know how to extract residuals for
data values themselves in the Lavaan package?
Here is the code I am using to construct my model and the model that I am
trying to get the residuals for:
#Specify the model
> model2BIOVre <- 'BIOVOL ~ LOG_NTL + LOG_PTL + b1*LOG_SR_A_D
+ LOG_NTL ~~ LOG_PTL
+ LOG_NTL ~~ LOG_SR_A_D
+ b1 == 0'
#Fit the model with the sem function
> fit <- sem(model2BIOVre, data=lakes, fixed.x=FALSE, estimator="MLM")
#Summarize model
> summary(fit, fit.measures=TRUE, standardize=TRUE, rsq=TRUE)
Here is where I am stumped...I have read the package manuals, and tutorials
located at lavaan.urgent.be, as well as some by James Grace. I have also
tried to manipulate some other codes, but I can't get it.  I may have
missed something as I am relatively new to R, but it is not clear to me how
to do this.
Any help would be very much appreciated.
Thank you,
Emily Zimmerman

	[[alternative HTML version deleted]]

