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