Estimating a simple Confirmatory Factor Analysis (CFA) model with lavaan
gives inconsistent results when I use cfa
and lavaan(method = "cfa")
.
library(lavaan)
10 observations, four indicators
foo <- structure(list(ind1 = c(0.2, -1, -0.2, 0.6, 0.6, -0.2, -0.2,
-1, 0.6, 0.2),
ind2 = c(0.6, -0.2, -0.2, 0.6, 0.6, -0.2, -1,
-1, 0.6, 0.6),
ind3 = c(0.6, -0.2, -0.2, 0.6, 0.2, 0.2, -0.6,
0.6, 0.6, 0.6),
ind4 = c(1, -0.5, -1, 0.5, 0.5, -0.5, 0, 0, -0.5,
0.5)),
codepage = 65001L, .Names = c("ind1", "ind2", "ind3", "ind4"),
row.names = 1:10,
class = "data.frame")
This model
cfa(model = 'latent =~ ind1 + ind2 + ind3 + ind4', data = foo)
Works fine. But this, which I thought was equivalent
lavaan(model = 'latent =~ ind1 + ind2 + ind3 + ind4',
data = foo,
model.type = "cfa")
causes an error:
Error in lav_model_estimate(lavmodel = lavmodel, lavsamplestats = lavsamplestats, :
lavaan ERROR: initial model-implied matrix (Sigma) is not positive definite;
check your model and/or starting parameters.
What am I missing?