2

I want to fit the Kenny and Judd (1984) model below:

y = alpha + gamma1 * psi1 + gamma2 * psi2 + gamma3 * psi1 * psi2 + epsilon

The variables psi1 and psi2 are latent variables that are not directly observable. Kenny and Judd (1984) considered the case when there are two observable indicators x1 and x2 of psi1 and two observable indicators x3 and x4 of psi2. I want to create this model in R using lavaan package.

Code:

model <- '
psi1 =~ x1 + x2
psi2 =~ x3 + x4
'
fit <- sem(model,data=data)

Can anyone help me complete this code to obtain the interaction above?

L. Bakker
  • 147
  • 1
  • 13
Günal
  • 751
  • 1
  • 14
  • 29
  • 1
    I think you can start with defining the interaction variables themselves before adding them to the model, something like: intervar1 <- gamma1*psi1 – rdatasculptor Apr 28 '15 at 15:32
  • 1
    Maybe this thread can be of any help:https://groups.google.com/forum/m/#!topic/lavaan/ZnRn9O6yWrA – rdatasculptor Apr 28 '15 at 15:41

1 Answers1

3

In case anyone is still searching in 2021, you can indeed specify categorical variables and interactions in lavaan (going up to three-way at present).

(1) You can use the group by function to specify a group with multiple levels, for example:

MyModel <- sem(my.lavaan.model, Data, group="MyMultiLevelGroup")

(2) You can also specify interaction terms using ":" within the lavaan model itself, for example:

my.lavaan.model <- '
y ~ x1 + x2 + x1:x2'

(3) Therefore, by combining steps (1) & (2) above you could specify a three-way interaction, between x1, x2 and MyMultiLevelGroup e.g.:

my.lavaan.model <- '
y ~ x1 + x2 + x1:x2'

MyModel <- sem(my.lavaan.model, Data, group="MyMultiLevelGroup")

This will display the results of an interaction between x1 and x2, at each level of MyMultiLevelGroup.

Shawn Hemelstrand
  • 2,676
  • 4
  • 17
  • 30
JoeyyyFunk
  • 70
  • 7