using Lavaan to test moderation effect

594 views
Skip to first unread message

Sarah Yixin Zhang

unread,
Feb 26, 2018, 11:34:27 AM2/26/18
to lavaan
I want to test the following moderation model

All the constructs are latent constructs. Empowerment is a second order reflective construct.


may I know
1) how to create interaction terms?
I googled, and seems indProd can be used, but I do not understand the exact syntax.

For example, for the interaction term of empowerment and history tracking feature,
is that I can write
indProd(dat1, var1=c("histo1","histo2","histo3"), var2=empower, match=FALSE, meanC=TRUE,  residualC=FALSE, doubleMC=TRUE)

2) how to write the interaction regression?
browse ~ empower + histo + sys + interaction_term
but how to write the interaction term?

Thank you very much!

Sarah

Sarah

unread,
Feb 26, 2018, 5:40:50 PM2/26/18
to lavaan

I do not know how to create the moderation item, for empower x histo, and empower x sys.

 

Empowerment - empower is  a second order reflective construct, with the dimension comp, mean, aut and imp. 

Empowerment interacts with history tracking (histo) to influence browse. History tracking is a first order reflection latent construct. 

Empowerment also interacts with system facilitating social interactions (sys) to influence browse. System facilitating social interactions is a first order reflection latent construct.

 

library('lavaan')

dat1 <- read.csv("C:/Users/Sarah/Documents/community.csv")

 

mySEMModel2 <- 'comp =~ comp1 + comp2 + comp3

mean =~ mean1 + mean2 + mean3

aut =~ aut1 + aut2 + aut3

imp =~ imp1 + imp2 + imp4

empower =~ comp + mean + aut + imp

 

browse =~ browse1 + browse2 + browse3

knowc =~ knowc1 + knowc2 + knowc3 + knowc4

sosp =~ sosp2 + sosp3 + sosp4 + sosp5

 

histo =~ histo1 + histo2 + histo3

sys =~ sys1 + sys2 + sys3

 

# regressions

#not sure how to create the interaction term

browse ~ empower + histo + sys + interaction term

 

fit <- sem(mySEMModel2, data = dat1)

summary(fit, standardized = TRUE, fit.measures = TRUE)

Mikko Rönkkö

unread,
Feb 27, 2018, 12:44:00 AM2/27/18
to lav...@googlegroups.com
Hi,

The basic approach is this:

library(lavaan)
library(semTools)

model <- '
  # measurement model
ind60 =~ x1 + x2 + x3
dem60 =~ y1 + y2 + y3 + y4
dem65 =~ y5 + y6 + y7 + y8
ind60dem60 =~ x1.y1 + x2.y2 + x3.y3

# regressions
dem65 ~ ind60 + dem60 + ind60dem60'

fit <- sem(model, data = orthogonalize(PoliticalDemocracy, c("x1", "x2", "x3"), c("y1", "y2", "y3")))
summary(fit, standardized=TRUE)

Different variants of the technique are produced by:
1) adding constraints to loadings, possibly from previously estimated models
2) creating the interaction indicators differently

You can also check out this package, which implements the LMS approach


Mikko


--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

Alex Schoemann

unread,
Feb 27, 2018, 10:49:23 AM2/27/18
to lavaan
Mikko's code is a nice example. One note in this case is that the product indicator method has not been evaluated using a higher order construct as part of the interaction. I'm not 100% sure how you would set that up. I think Sarah has two options:

1. Create composites for the first order latent variables of empowerment, use these as indicators of empowerment and to compute indicators of the latent interaction variable using indprod (using either a double mean centering or residual centering approach). 
2. Use the LMS approach implemented in nlsem

Alex

Mikko Rönkkö

unread,
Feb 27, 2018, 11:07:35 AM2/27/18
to lav...@googlegroups.com
Alex, Sarah,

Right. I did not read the question thoroughly. I do not think that approximating the latent variables with sums of the indicators is a good idea because it will lead to biased estimates of the original model parameters. 

Using the selectively to form the interaction terms should work in principle, but it would be an inefficient approach. One way around this problem would be leveraging the fact that a higher order model is a special case of a bifactor model. (e.g. doi:10.3390/jintelligence5030027), in which case this would reduce to a first level model with appropriate constraints.

But perhaps LMS would be the easiest approach for this.

Mikko

Sarah

unread,
Feb 27, 2018, 4:09:24 PM2/27/18
to lavaan
Mikko, Alex, thank you both very much!

Now I can run the model in Mplus using xwith.

And I think this question and answer is relevant to mine.

It seems testing interaction which involves latent variable is not yet that straight forward in Lavaan, i.e. cannot be done by one operator. (And it seems : operator is being implemented for next version of Lavaan)

In my case it involves a first order latent variable, and a second order reflective latent variable.

I'm not familiar with LMS, but hope it can do this. Again, many thanks! 


Yves Rosseel

unread,
Mar 19, 2018, 5:24:48 AM3/19/18
to lav...@googlegroups.com
On 02/27/2018 10:09 PM, Sarah wrote:
> It seems testing interaction which involves latent variable is not yet
> that straight forward in Lavaan, i.e. cannot be done by one operator.

That is true.

> (And it seems : operator is being implemented for next version of Lavaan)

Not for latent variables!!

(Only for simply interactions among observed exogenous covariates).

Yves.
Reply all
Reply to author
Forward
0 new messages