How can an SEM model be fitted when the dataset includes both continuous and categorical variables?
1 Answer
That will depend on the model. When you are fitting a model with an exogenous binary categorical variable (e.g. males and females) or an exogenous ordinal variable with a clear ordering, then you can fit the variable as dummy-coded. With categorical endogenous variables, you would have to fit the model using something like diagonally weighted least squares (in lavaan this would involve the WLSMV estimator).
If you are not interested in latent variables, and are open to not using covariance matrix-based SEM, then you can easily use whatever categorical variables you want in piecewise SEMs, which only requires fitting the linear model of your choosing into each path like you typically would.
-
$\begingroup$ Thank you for your response. I am interested in the Covariance-Based SEM method, which is indeed based on the covariance matrix. However, I am wondering how the empirical covariance matrix is computed when the type of observed variable is categorical (binary, ordinal, nominal). $\endgroup$SABAH– SABAH2025-03-21 16:08:33 +00:00Commented Mar 21 at 16:08
-
2$\begingroup$ For exogenous variables that are dummy-coded there is no difference. For WLSMV estimators,
lavaanwill calculate the polychoric correlations and then calculate a weight matrix from the asymptotic covariance matrix. The path estimates become the change in the response on a standardized z scale for each unit change in the predictor. See more about that here. $\endgroup$Shawn Hemelstrand– Shawn Hemelstrand2025-03-23 00:30:53 +00:00Commented Mar 23 at 0:30 -
$\begingroup$ Yes, I tried using the WLSMV estimator, but unfortunately, I encountered an error: "unordered factor(s) detected." This happens with a model that has nominal latent variable indicators. $\endgroup$SABAH– SABAH2025-03-25 03:53:01 +00:00Commented Mar 25 at 3:53
-
2$\begingroup$ This is more a coding question than a statistics question, but perhaps you can ask a new or edited question with your model syntax explicitly written out so others can see what you did to get this error. $\endgroup$Shawn Hemelstrand– Shawn Hemelstrand2025-03-25 04:30:58 +00:00Commented Mar 25 at 4:30
-
2$\begingroup$ For nominal data see Revuelta, J., Maydeu-Olivares, A., & Ximénez, C. (2020). Factor analysis for nominal (first choice) data. Structural Equation Modeling: A Multidisciplinary Journal, 27(5), 781-797. $\endgroup$Preston Botter– Preston Botter2025-03-25 17:34:47 +00:00Commented Mar 25 at 17:34