The blavaan multilevel testing continues! This pr addresses a lavPredict() bug when there are between-only variables. The data from those variables were not being included in the level 2 lv predictions.
The example below uses the data from "school.dat". It has a negative variance estimate, and I should probably add a third between-only variable. But it should be enough to demonstrate the problem.
model <- '
level: within
fw =~ y6 + y7 + y8 + y9
level: between
fb =~ y6 + y7 + y8 + y9
fb2 =~ x3 + x4 '
fit <- sem(model, data = Data, cluster = "school")
out <- lavPredict(fit, level = 2)
cor(out) # lv correlation is 1
The blavaan multilevel testing continues! This pr addresses a lavPredict() bug when there are between-only variables. The data from those variables were not being included in the level 2 lv predictions.
The example below uses the data from "school.dat". It has a negative variance estimate, and I should probably add a third between-only variable. But it should be enough to demonstrate the problem.