Hi all,
Is it possible to run sem with a an interaction variable on the lhs of the regression by using the : operator. I have tried (please see example below) but I get the following error
Error in lavParseModelString(model) :
lavaan ERROR: left hand side (lhs) of this formula:
dem65:ind60 ~ dem60
contains either a reserved word (in R) or an illegal character: “dem65:ind60”
See ?reserved for a list of reserved words in R
Please use a variable name that is not a reserved word in R
and use only characters, digits, or the dot symbol.
Is this a bug of the command? Please see a very simple example below to illustrate the error
model <- '
# measurement model
ind60 =~ x1 + x2 + x3
dem60 =~ y1 + y2 + y3 + y4
dem65 =~ y5 + y6 + y7 + y8
# regressions
dem65:ind60 ~ + dem60
# residual correlations
y1 ~~ y5
y2 ~~ y4 + y6
y3 ~~ y7
y4 ~~ y8
y6 ~~ y8
'
fit <- sem(model, data = PoliticalDemocracy)
Many thanks