Multilevel models in Lavaan

Hello,

I would like to compute a multilevel model (random intercept random slope) in R. Dependent variables (Affect) and independent variables (ICT and Gewissenhaftigkeit). All variables are at level-1. The estimation method to be used is the Full-Information-Maximum Lieklihood method. The ID variable is called SERIAL. However, I get this error message: Error in lav_syntax_parse_rhs(rhs = rhs.formula[[2L]], op = op) :
lavaan ERROR: I'm confused parsing this line: |sSERIAL

specification of model

model <- '

Random-Intercept-model

Affekt ~ 1 + IKT + Gewissenhaftigkeit 
# Random-Slope-model
IKT ~ 1 + Gewissenhaftigkeit
# interaction
Affekt ~ IKT:Gewissenhaftigkeit

Definition of random effects

Affekt ~ s | SERIAL
IKT ~ s + Gewissenhaftigkeit | SERIAL

Definition of Levels

Affekt ~~ 1*Affekt
IKT ~~ 1*IKT
Gewissenhaftigkeit ~~ 1*Gewissenhaftigkeit

'

Estimate Model

fit <- sem(model, data = Tabelle, estimator = "MLR", missing = "ML")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.