| Demo.twolevel {lavaan} | R Documentation |
Demo dataset for a illustrating a multilevel CFA.
Description
A toy dataset containing measures on 6 items (y1-y6), 3 within-level covariates (x1-x3) and 2 between-level covariates (w1-w2). The data is clustered (200 clusters of size 5, 10, 15 and 20), and the cluster variable is “cluster”.
Usage
data(Demo.twolevel)
Format
A data frame of 2500 observations of 12 variables. clusters.
y1item 1
y2item 2
y3item 3
y4item 4
y5item 5
y6item 6
x1within-level covariate 1
x2within-level covariate 2
x3within-level covariate 3
w1between-level covariate 1
w2between-level covariate 2
clustercluster variable
Examples
head(Demo.twolevel)
model <- '
level: 1
fw =~ y1 + y2 + y3
fw ~ x1 + x2 + x3
level: 2
fb =~ y1 + y2 + y3
fb ~ w1 + w2
'
fit <- sem(model, data = Demo.twolevel, cluster = "cluster")
summary(fit)
[Package lavaan version 0.6-18 Index]