How do I integrate a categorical IV and a continuous moderator (from CFA) interaction in a SEM framework using lavaan in R?

How can I model an interaction between a categorical predictor and a continuous moderator (from CFA) in SEM using lavaan in R? Workarounds or Mplus alternatives?

Hey Oliver63, I was tinkering around with a pretty similar situation recently and found it a bit of a puzzle to get your categorical IV and continuous moderator interacting within lavaan. One workaround that I played with was to generate an interaction term manually outside the model – essentially coding your categorical variable as dummy variables and then multiplying it by your continuous moderator. Then, you can incorporate these interaction terms into your SEM model in lavaan. It might not be as elegant as directly specifying latent variable interactions like in Mplus with the XWITH command, but it has worked decently for me.

I wonder if you’ve tried even partitioning the analysis into multiple groups or using a moderator variable analysis approach? It’d be cool to hear if anyone else has alternative strategies that handle this within lavaan in a more straightforward manner. How have you approached the creation of such interaction terms so far? Any tips for smoothing out potential issues with scaling or interpretability? Would love to hear some success stories or even stumbling blocks others have encountered! :blush: