How do I classify binary indicator variables in SEM using WLSMV in R (lavaan)

90 views Asked by At

I am developing a SEM using lavaan in R. I have continuous, ordinal and binary variables. I keep getting the following error codes for my binary variables (set as.factor) when I try to run the model using WLSMV

e.g. Error in lav_data_full(data = data, group = group, cluster = cluster, : lavaan ERROR: unordered factor(s) detected; make them numeric or ordered: home_owner

I have been trying to specify them as a factor with 2 levels (0, 1). I don't want to make the variable order or numeric as it is a binary variable. What should I do? I thought WLSMV was specifically for categorical variables so I don't understand the issue.

The code will work if I set the variables as ordered or numeric, but this doesn't feel right.

1

There are 1 answers

1
Terrence On

I don't want to make the variable order or numeric as it is a binary variable.

Binary is a special case where there is no distinction between nominal and ordinal. You can always view a dummy coded variable as ordinal in the extreme sense that it either has all of the quality or none of it.

From a more practical perspective, the same mechanism is required to incorporate a binary endogenous variable into an SEM using DWLS estimation: you assume a normally distributed latent response underlying the 2 categories. You could interpret this a "propensity" for being a homeowner, for example.

So you simply set it to be an ordered factor. Or if it is only a predictor (not an outcome), you just leave it as a numeric dummy code.

https://lavaan.ugent.be/tutorial/cat.html