demo/twolevel.R

# lavaan's Demo.twolevel data set: 2500 observations clustered within 200
# groups, with separate within- and between-level measurement/structural
# models
mod <- "
  level: 1
    fw =~ y1 + y2 + y3
    fw ~ x1 + x2 + x3
  level: 2
    fb =~ y1 + y2 + y3
    fb ~ w1 + w2
"
fit <- asem(mod, lavaan::Demo.twolevel, cluster = "cluster")

Try the INLAvaan package in your browser

Any scripts or data that you put into this service are public.

INLAvaan documentation built on Oct. 2, 2026, 1:07 a.m.