Scatterplot with regression line for SEM model

70 views
Skip to first unread message

Jenny D.

unread,
Sep 25, 2022, 1:59:47 PM9/25/22
to lavaan
Hello,

I used the SEM function so I could account for missingness with FIML in my regression models, but I am confused about how to plot those models as scatterplots with the regression line and partial residuals, like one would find with ggplot. 

Is this possible? I can only seem to find functions to plot path diagrams.Thanks in advance!

Terrence Jorgensen

unread,
Oct 8, 2022, 4:01:53 AM10/8/22
to lavaan
I used the SEM function so I could account for missingness with FIML in my regression models, but I am confused about how to plot those models as scatterplots with the regression line and partial residuals

You can make the scatterplot with your data:

plot(x = ..., y = ...)

Then add your regression slope using the abline() function.  This post might help with ggplot2:


If by "partial residuals" you mean you want to plot y by residuals of x after partialling out other predictors, I think you would have to regression x on your other covariates, then calculate residuals manually (for complete cases) using the regression parameters to calculate the predicted values.  Then make your scatterplot of data points, and add the regression line for x's effect.

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

Reply all
Reply to author
Forward
0 new messages