Quy Pham
Quy Pham

Reputation: 1

clustering in Lavaan for structural equation model

I am trying to fit SEM in lavaan that includes both a measurement and structural model. The measurement model consists of six latent variables, which serve as outcomes in the structural model. The structural model includes Year as a predictor.

Model 1 (Without Clustering): The model fits the data adequately.

Model 2 (With Clustering): When I include clustering by university (students are nested within 12 universities), I receive the following warning: Warning: lavaan->lav_model_vcov(): The variance-covariance matrix of the estimated parameters (vcov) does not appear to be positive definite! The smallest eigenvalue (= -5.896148e-11) is smaller than zero. This may be a symptom that the model is not identified. The overall model fit is fine, though.

My data contains over 1,000 students from 12 universities. The Year variable has 4 levels: Year 1, Year 2, Year 3, and Year 4. However, not all universities have data for all 4 levels of Year—some universities only have 1 or 2 levels.

My questions:

  1. Could the absence of some Year levels within certain universities be leading to this issue? If so, I should not include "cluster" in the code right?
  2. Since the model with the cluster is problematic, would it be more appropriate to report the model without clustering? When I tried to compare the two models, there is an error: lavaan->lavTestLRT(): some models (but not all) have a meanstructure. So I think I cannot compare them and just need to report the model without the warning. Am I right in thinking so?
  3. Is there any way for me to fit the model with missing levels for certain clusters (universities) in R?

The R codes:

 model<- 
 Factor1 =~ Item1 + Item2 + Item3 + Item4 
 Factor2 =~ Item5 + Item6 + Item7 + Item8
 Factor3 =~ Item9 + Item10 + Item11 + Item12
 Factor4 =~ Item13 + Item14 + Item15 + Item16 + Item17 + Item18
 Factor5 =~ Item19 + Item20 + Item21 + Item22
 Factor6 =~ Item23 + Item24 + Item25 + Item26

 Factor1 ~ Year2Sophomore + Year2Junior + Year2Senior
 Factor2 ~ Year2Sophomore + Year2Junior + Year2Senior
 Factor3 ~ Year2Sophomore + Year2Junior + Year2Senior
 Factor4 ~ Year2Sophomore + Year2Junior + Year2Senior
 Factor5 ~ Year2Sophomore + Year2Junior + Year2Senior
 Factor6 ~ Year2Sophomore + Year2Junior + Year2Senior

 Fit1 <- sem(model, data = df10, estimator = "MLM", std.lv = TRUE) – overall fit is acceptable
 Fit2 <- sem(model, data = df10, estimator = "MLM", std.lv = TRUE, cluster =     "University") - overall fit is also acceptable but with the above warning. 

I highly appreciate your help. Thank you!

Upvotes: 0

Views: 36

Answers (0)

Related Questions