Ed Merkle, PhD
Assistant Professor
Department of Psychological Sciences
University of Missouri
Columbia, MO, USA 65211
On 7/9/12 1:25 PM, r-help-request at r-project.org wrote:
> Date: Mon, 9 Jul 2012 11:41:33 -0400
> From: Emily Zimmerman<zimmerman.em.k at gmail.com>
> To:r-help at r-project.org
> Subject: [R] Lavaan Package - How to Extract Residuals in Data Values
> Message-ID:
> <CABC6T6d-ezgpwYCskaDpvwq3=pGRy8Tb9=4v3va-9gJBNnkTQw at mail.gmail.com>
> Content-Type: text/plain
>
> 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