Error for SEM regression with binary dependent variable, continuous and binary independent variables

82 views
Skip to first unread message

Question

unread,
Dec 7, 2024, 1:50:48 AM12/7/24
to lavaan
When I fit the following model, it works with no error:

model1 <- 'binary_dep ~  continuous_var1 + continuous_var2 + binary_ind'
fit <- sem(model1,  data = analysis_set, ordered="binary_dep", std.lv = TRUE)

Where 'binary_ind' is defined as numeric with values 0 or 1, 'binary_dep' is an ordered factor.


Similarly, the following model with binary_ind removed and a correlation defined between the continuous variables works with no error:

model2 <- 'binary_dep ~  continuous_var1 + continuous_var2
                 continuous_var1 ~~ continuous_var2'
fit <- sem(model2,  data = analysis_set,  ordered="binary_dep", std.lv = TRUE)


But the model I want to run which combines these 2 ideas - the regression as well as the correlation between the continuous variables - does not work:

model3 <- 'binary_dep ~  continuous_var1 + continuous_var2 + binary_ind
                 continuous_var1 ~~ continuous_var2'
fit <- sem(model3, data = analysis_set, ordered="binary_dep", std.lv = TRUE)

Error: lavaan->lav_model():  
   a model parameter is not defined in the LISREL representation binary_dep ~ continuous_var1. Upgrade to latent variables or consider
   using representation = 'RAM'.



I've tried setting it to have representation = 'RAM', but then I see:
Error: lavaan->lav_ram():  
   RAM representation is not (yet) supported for categorical endogenous variables.


If I change binary_dep to be numeric and use representation = 'RAM', remove ordered = "binary_dep", then the model does run successfully, but I'm no longer predicting an ordered factor outcome, and it's instead viewing binary_dep as a continuous variable on the range 0 to 1.

Very confused what to try next... is there any way to make model3 run without error?

Thanks in advance for any help










Question

unread,
Dec 7, 2024, 1:25:49 PM12/7/24
to lavaan
I've found a workaround to fit model 3 which is to force the continuous variables to be latent variables:

model3 <- '
                  latent_continuous_var1 =~ continuous_var1
                  latent_continuous_var2 =~ continuous_var2

                  binary_dep ~  latent_continuous_var1 + latent_continuous_var2 + binary_ind
                
                 latent_continuous_var1 ~~ latent_continuous_var2
'

fit <- sem(model3, data = analysis_set, ordered="binary_dep", std.lv = TRUE)


This works and gives results that are in line with expectations, but still unsure what lead to the original error
Reply all
Reply to author
Forward
0 new messages