# Latent moderated Regression / SEM in Lavaan

I am trying to build a SEM in lavaan to determine the stability of a personality trait across three measurement time points. As per the theory the stability of a trait is given by the standardized effect of the trait when measured before. (for example, the standardized effect from T1 to T2 or from T2 to T3). In doing so, I want to add age as a moderator that interact with T1 or T2, but am having trouble implementing this in Lavaan under the regressions term. The measurement model works fine.

This is what my code looks like so far:

lmsNeugierde <- '
#measurement model
NeugierdeT1 =~ a*SQ1_bfi_open_2 + b*SQ1_bfi_open_5R + c*SQ1_bfi_open_8 + d*SQ1_bfi_open_11R
NeugierdeT2 =~ a*SQ2_bfi_open_2 + b*SQ2_bfi_open_5R + c*SQ2_bfi_open_8 + d*SQ2_bfi_open_11R
NeugierdeT3 =~ a*SQ3_bfi_open_2 + b*SQ3_bfi_open_5R + c*SQ3_bfi_open_8 + d*SQ3_bfi_open_11R

SQ1_bfi_open_2  ~ (MA)*1
SQ2_bfi_open_2  ~ (MA)*1
SQ3_bfi_open_2  ~ (MA)*1

SQ1_bfi_open_5R ~ (MB)*1
SQ2_bfi_open_5R ~ (MB)*1
SQ3_bfi_open_5R ~ (MB)*1

SQ1_bfi_open_8 ~ (MC)*1
SQ2_bfi_open_8 ~ (MC)*1
SQ3_bfi_open_8 ~ (MC)*1

SQ1_bfi_open_11R ~ (MD)*1
SQ2_bfi_open_11R ~ (MD)*1
SQ3_bfi_open_11R ~ (MD)*1

SQ1_bfi_open_2 ~~ SQ2_bfi_open_2 + SQ3_bfi_open_2
SQ2_bfi_open_2 ~~ SQ3_bfi_open_2

SQ1_bfi_open_5R ~~ SQ2_bfi_open_5R + SQ3_bfi_open_5R
SQ2_bfi_open_5R ~~ SQ3_bfi_open_5R

SQ1_bfi_open_8 ~~ SQ2_bfi_open_8 + SQ3_bfi_open_8
SQ2_bfi_open_8 ~~ SQ3_bfi_open_8

SQ1_bfi_open_11R ~~ SQ2_bfi_open_11R + SQ3_bfi_open_11R
SQ2_bfi_open_11R ~~ SQ3_bfi_open_11R

#Regressions
NeugierdeT2 ~ NeugierdeT1*SQ1_age + SQ1_ageZ + SQ1_sex
NeugierdeT3 ~ NeugierdeT2*SQ1_age + SQ1_ageZ + SQ1_sex
'

lmsNeugierdefit <- sem(lmsNeugierde, data = daten, missing = "fiml")
summary(lmsNeugierdefit, fit.measures=TRUE, standardize = TRUE)


Any help would be highly appreciated since I have been struggling with this for quite a while now and have not found a solution yet

You could use the product-indicator approach. We have lavaan syntax in this chapter, available on ResearchGate: https://doi.org/10.1007/978-3-319-77249-3_20
You could also use moderated nonlinear factor analysis (MNLFA), which is not implemented in lavaan. It was developed using SAS and Mplus, but we have an accepted preprint on the OSF showing how to implement it in the R package OpenMx: https://osf.io/6cyxt/