Dear All,
Any one can help to fix the following issue?
When I run the following code with the attached data set,
model<-'
level: 1
AW=~A1+A2+A3+A4+A5+A6+A7+A8
NW=~N1+N2+N3+N4+N5+N6+N7+N8+N9
GW=~G1+G2+G3+G4
NW~AW+1
GW~NW+1
level:2
AB=~A1+A2+A3+A5+A7+A8
NB=~N1+N2+N3+N5+N6+N8+N9
GB=~G1+G2+G3+G4
NB~AB+1
GB~NB+B+1
B~Q+1'
fit <- sem(model = model, data = aa, cluster = "Hotel")
if I use the default estimation method, I got the following warning
Warning message:
In lavaan::lavaan(model = model, data = aa, cluster = "Hotel", model.type = "sem", :
lavaan WARNING: the optimizer warns that a solution has NOT been found!
And all the Std.Errs are zero.
If I swapped to EM estimation
fit <- sem(model = model, data = aa, cluster = "Hotel",verbose = TRUE, optim.method = "em", em.iter.max = 200000),
The warnings are as follows
Warning messages:
1: In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, :
lavaan WARNING:
The variance-covariance matrix of the estimated parameters (vcov)
does not appear to be positive definite! The smallest eigenvalue
(= -9.831438e+05) is smaller than zero. This may be a symptom that
the model is not identified.
2: In lav_object_post_check(object) :
lavaan WARNING: some estimated ov variances are negative
3: In lavaan::lavaan(model = model, data = aa, cluster = "Hotel", verbose = TRUE, :
lavaan WARNING: not all elements of the gradient are (near) zero;
the optimizer may not have found a local solution;
use lavInspect(fit, "optim.gradient") to investigate
And the Std Err of some intercepts in the 2nd level are NA.
Would you please help to explain what are the reasons and how to fix this? Thank you very mcuh
Regards
Anyu