NA st dev of some parameters in multi-level SEM

30 views
Skip to first unread message

Anyu Liu

unread,
Dec 9, 2018, 1:09:21 PM12/9/18
to lavaan
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
data_merged_m.csv

Terrence Jorgensen

unread,
Dec 9, 2018, 1:29:38 PM12/9/18
to lavaan
And the Std Err of some intercepts in the 2nd level are NA.

Why are you estimating intercepts of latent factors?  Even with single-level models, they are not identified unless you fix an indicator's intercept to zero.  I would just let the factor (NW, NB, GW, and GB) intercepts remain fixed to zero for identification, which is lavaan's default behavior.

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Anyu Liu

unread,
Dec 9, 2018, 1:54:36 PM12/9/18
to lavaan
Hi Terrence,
Thanks for your reply. After I removed the estimation of intercepts, I got the same warnings. There are four NAs in the Std Errors in the 2nd level.

Would you please have a further look at it? The code is as follows
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
GW~NW

level:2
AB=~A1+A2+A3+A4+A5+A6+A7+A8
NB=~N1+N2+N3+N4+N5+N6+N7+N8+N9
GB=~G1+G2+G3+G4
NB~AB
GB~NB+B
B~Q

'
fit <- sem(model = model, data = aa, cluster = "Hotel",verbose = TRUE, optim.method = "em", em.iter.max = 200000)

Thanks.

Regards
Anyu

Anyu Liu

unread,
Dec 10, 2018, 5:40:35 PM12/10/18
to lavaan
Anyone could help on this? Thanks!
Reply all
Reply to author
Forward
0 new messages