yrosseel/lavaan

lavPredict warning / error when no latent variables

karchjd opened this issue · 1 comments

Very minor, but this

library(lavaan)
model <- 'x4 ~ x1'
fit <- cfa(model, data = HolzingerSwineford1939)
fscores <- lavPredict(fit)

results in a matrix with 301 rows and 0 columns. I would suggest that this should result in an error or at least in a warning. So, error or warning for lavPredict if model contains no latent variables.

I opted for a warning:

Warning message: lavaan->lavPredict(): fitted model does not contain regular (i.e., measured) latent variables; the matrix of factor scores may contain no columns

But I would still return an empty (Nx0) matrix.