Plot interaction

514 views
Skip to first unread message

Nathalie Aerts

unread,
May 14, 2021, 9:53:56 AM5/14/21
to lavaan
Dear all,

For my master's thesis, I am using a SEM approach. I have an ordinal DV = studying abroad (no, probably, yes). I want to plot the interaction between social origin (both parents higher education, only father, only mother, none of the parents higher educated) and year (continuous). I tried everything to my knowledge, however, noting has worked yet. There are also 3 factors in my model. Is there a possibility to compute the simple slopes by hand? Thank you in advance!

model2 <-'
# Measurement part
soc.peers =~ V382 + V388
soc.uni =~ V385 + V386 
cult =~ V444 + V447 + V452

soc.peers ~~ cult + soc.uni
soc.uni ~~ cult

#Strucutral part 
soc.peers ~ female + none + father + mother + year + university + grade + age + semester
soc.uni ~ female + none + father + mother + year + university + grade + age + semester
cult ~ female + none + father + mother + year + university + grade + age + semester
V361 ~  none + father + mother + university + year + female + grade + age + semester
abroad ~  none + father + mother + university + year + soc.uni + soc.peers + cult + female + grade + age + V361 + semester + y.mother + y.father + y.none 
'

Mauricio Garnier-Villarreal

unread,
May 14, 2021, 8:32:29 PM5/14/21
to lavaan
Hi

Look at the functions probe2WayMC() and plotProbe() from semTools.
These way you can estimate the simple slopes, and plot them, for 2 way interactions

Nathalie Aerts

unread,
May 17, 2021, 5:40:14 AM5/17/21
to lavaan
Hi,

Thank you for you reply. Unfortunately, I cannot use the probe2Way and plotProbe functions because they only work when you use latent variables.
My interaction consists of twee observed variables. 

Op zaterdag 15 mei 2021 om 02:32:29 UTC+2 schreef mauga...@gmail.com:

Mauricio Garnier-Villarreal

unread,
May 17, 2021, 7:28:26 AM5/17/21
to lavaan
Nathalie

You can get the neccesary information from lavaan and put it into this website http://www.quantpsy.org/interact/mlr2.htm

This also gives you the R code

Nathalie Aerts

unread,
May 17, 2021, 8:41:11 AM5/17/21
to lavaan

Thank you again!
Op maandag 17 mei 2021 om 13:28:26 UTC+2 schreef mauga...@gmail.com:

Nathalie Aerts

unread,
May 17, 2021, 8:50:01 AM5/17/21
to lavaan
I am familiar with this webpage, however, I do not understand how to use it. Additionally, my DV is ordinal, so I am not sure whether I can use the webpage.
What I don't understand is how I get the intercept (b0), and the variances. 

Op maandag 17 mei 2021 om 14:41:11 UTC+2 schreef Nathalie Aerts:

Mauricio Garnier-Villarreal

unread,
May 19, 2021, 4:22:34 PM5/19/21
to lavaan
For the betas, you use the estimates from the summary() or parestimates() function from lavaan. for the parameter covariance you can use the vcov(fit) function, this will give you he variance/covariance matrix between parameter. You can subselect only the parameter you need to see the smaller matrix with the parameters you need

How many categories does your outcome has? I think you can still use this, because lavaan will give you the probit regression for categorical outcome. And the probit estimate is still an estimate of the linear relation, but linear with the ojive transformation. So, the visualization will present the linear probist relation, which can be hard to interpret.

Another option would be to estimate the simple slopes for the values of interest. And then use those estimates to transform the probit estimates to probabilities, and create the change in probablity plots on your own for each probit simple slopes. This woul be more coding work, but would lead to more meaningful plots

Nathalie Aerts

unread,
May 20, 2021, 10:58:45 AM5/20/21
to lavaan
Alright, I will try to calculate the simple slopes!

Op woensdag 19 mei 2021 om 22:22:34 UTC+2 schreef mauga...@gmail.com:

MD Oliur Rahman Tarek

unread,
May 2, 2025, 1:09:36 PM5/2/25
to lavaan
Hi, 

Thanks so much for the info. I am stuck with kind of similar issues. 
Just a follow-up question, how can you subset inside a vcov function? I just need to get the variance-covariance matrix of the regression coefficients in order to use them for plotting purposes. 

Thanks so much in advance. 

best regards, 
Tarek

Reply all
Reply to author
Forward
0 new messages