if (FALSE) {
data(HolzingerSwineford1939, package = "lavaan")
## fit model
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
fit <- bcfa(HS.model, data = HolzingerSwineford1939)
## 1 dataset generated from the posterior
out <- sampleData(fit, nrep = 1)
## nested lists: 1 list entry per nrep.
## then, within a rep, 1 list entry per group
## so our dataset is here:
dim(out[[1]][[1]])
## 1 posterior dataset per posterior sample:
out <- sampleData(fit)
## obtain the data on x1 across reps and summarize:
x1dat <- sapply(out, function(x) x[[1]][,1])
summary( as.numeric(x1dat) )
}
Run the code above in your browser using DataLab