cjvanlissa / tidySEM

57 stars 7 forks source link

Combining Continuous and Categorical Indicators in LCA #103

Open linem7 opened 2 months ago

linem7 commented 2 months ago

Dear Dr. Van Lissa,

I’ve been using the tidySEM package, following recommendations from your paper, "Recommended Practices in Latent Class Analysis Using the Open-Source R-Package tidySEM", to conduct my study. However, I’ve encountered a situation where my latent class analysis model includes both continuous and categorical indicators. Since this scenario wasn't explicitly covered in the paper, I’m wondering if it’s possible to handle such a model using the tidySEM package.

Could you please advise if tidySEM supports models with both continuous and categorical indicators, or if I should consider alternative approaches (e.g., using Mplus) to address this issue?

Thank you for your assistance!

Best, Lin

cjvanlissa commented 2 months ago

Dear Lin,

in theory, this is possible - in practice, I've had severe convergence issues with this setup. You might be able to get it to work, but I'm not able to devote time to it right now.

linem7 commented 2 months ago

Dear Dr. Van Lissa,

Thank you so much for your quick response! I truly appreciate your insights. As I’m not confident that I can resolve this issue on my own, I will likely proceed with the Mplus approach for now. If I do manage to find a solution, I’d be honored to share it with you.

Your paper has been incredibly helpful for my research, and I’m very grateful for the guidance you’ve provided. Thank you once again for your support!

Best regards, Lin

cjvanlissa commented 2 months ago

Dear Lin,

you can give it a try, the model is not hard to specify using lavaan syntax. E.g.:

library(tidySEM)
dat <- read.table("https://www.statmodel.com/usersguide/chap7/ex7.12.dat")
dat[[6]] <- NULL
df <- dat
df[1:4] <- lapply(df[1:4], factor)
df <- mx_dummies(df)
df[grep("c0", names(df))] <- NULL
names(df) <- gsub(".c1", "", names(df))

res <- mx_mixture(model =
"V5 ~ m{C}*1
V5 ~~ varV5*V5
V1 | t1{C}
V2 | t2{C}
V3 | t3{C}
V4 | t4{C}", classes = 2, data = df, run = TRUE)

table_fit(res)

You can also send me your code + data for a double-check; my university email is in the package documentation.