3

I am using lavaan and have only observed variables (no latent variables). I would like to include an interaction term in the model, but not sure how to do this.

This is what I have

model4 <-'
interac =~ var1 * var2
Ent ~ age
presu ~ age + interac
protein ~ age + fat
fat ~ age
tempo ~ age +interac+protein
score ~sex+education+presu+tempo
'
fit <- sem(model4, data=mydata)
summary(fit4, fit.measures=TRUE)

(all variables have been scaled before starting, because I had some issues with some variables being 100 times larger than others).

I am wondering whether this is correct? I don't have the main effects of the interaction in the regression? Shouldn't these be included? When I add the interaction term directly in the regression (var1*var2), I get 1 as estimates, so that must be wrong...

user6121484
  • 143
  • 2
  • 15

1 Answers1

1

No, it is not correct. For manifest variables interaction, you have two alternatives:

1 - create the interaction term outside lavaan, e.g.:

mydata$interac <- mydata$var1 * mydata$var2

or

2 - use the : operator:

model4 <-'

Ent ~ age
presu ~ age + var1:var2 #interaction and age as predictors
protein ~ age + fat
fat ~ age
tempo ~ age + var1:var2 + protein #interaction, age and protein as predictors
score ~sex+education+presu+tempo
'
fit <- sem(model4, data=mydata)
summary(fit4, fit.measures=TRUE)
Sinval
  • 1,315
  • 1
  • 16
  • 25
  • 1
    I do not think this is correct. : seems to be used for reading variable names ... Package ‘lavaan’ June 27, 2021 ... Page 83: "Regressions: The "~" operator specifies a regression. The dependent variable is on the left of a "~" operator and the independent variables, separated by "+" operators, are on the right. These regression formulas are similar to the way ordinary linear regression formulas are used in R, but they may include latent variables. Interaction terms are currently not supported." ... The last sentence says "Interaction terms are currently not supported." – cibr Sep 19 '21 at 09:54
  • What are you referencing? I tried pulling this up on the package pdf and it only has about 40 pages: https://lavaan.ugent.be/tutorial/tutorial.pdf – Shawn Hemelstrand Sep 27 '22 at 00:41
  • @cibr, please see this answer: https://stats.stackexchange.com/a/553354/144370 – Sinval Sep 28 '22 at 15:41
  • @ShawnHemelstrand, I belive cibr is referring to this: https://cran.r-project.org/web/packages/lavaan/lavaan.pdf – Sinval Sep 28 '22 at 15:44