cjvanlissa / tidySEM

54 stars 7 forks source link

Missing data issue? Latent profile analysis #98

Closed follhim closed 2 days ago

follhim commented 4 days ago

Hello I'm reaching out today because I am having issues running an LPA model(s). When I remove NAs from the data, the model runs fine, but ofc that is a problem as we want to use what we can. From my understanding, mx_profiles() SHOULD use FIML automatically, but somehow that does not seem to be the case.

Now to be fair, three of the five variables are ordinal, but I want it to be treated as continuous (which is not an uncommon practice). However this is the error message I get:

lpa_data <- subset(data, select = c(sexualidentitysalience, lgbtconnect, relcom, serviceattendance, nora))

lpa_data <- sapply(lpa_data, as.numeric) lpa_data <- as.data.frame(lpa_data) res <- mx_profiles(data = lpa_data, classes = 1:6) Running mix1 with 10 parameters Could not initialize clusters using K-means, switching to hierarchical clustering. Error in tidySEM:::mixture_starts(model = new("MxModel", name = "mix2", : Could not initialize clusters using hierarchical clustering. Consider using a different clustering method, or imputing missing data.

TidyLPA does not allow for FIML, which is why I'm hoping to use the all powerful TidySEM. If anyone can please help, I would greatly appreciate it!

cjvanlissa commented 2 days ago

The model is not able to automatically determine starting values. Conducting a preliminary analysis on only complete cases, and using the resulting parameters as starting values for FIML with partially missing data, will likely solve your problem.

follhim commented 2 days ago

Thank you! How could I then use the resulting parameters as starting values for FIML?

I also have two questions related to auxiliary analyses, particularly covariates and distal outcomes. I understand that BCH() essentially performs the 3-step approach, but I'm confused about how it approaches covariates and distal outcomes.

For instance: How does one predict class membership (of the given data)? I know it's frowned upon to use multinomial regression since it does take into account error or the actual likelihood of class assignment. I was looking at the vignettes you provided and was unclear exactly what you were referring to. Is these the right?

covariates_model <- BCH(lpa1_solution, 
                        model = "class ~ education + age", 
                        data = lpa1_data)
summary(covariates_model)

Distal Outcomes

BCH(lpa1_solution, data = lpa1_data$dep) %>%
  lr_test()

Thank you! I've loved using TidySEM so far, and this offers a lot of things that tidyLPA doesn't!

cjvanlissa commented 1 day ago

Dear @follhim , unfortunately a lot of this just comes down to reading the documentation of OpenMx and tidySEM, and I can't give that kind of support! Maybe I'll record some instructional videos over the summer but can't promise anything

Gootjes commented 1 day ago

I wrote a similar analysis in R follhim! I can share the code with you. I did it slightly differently than CJ suggested, as his approach assumes MCAR for the starting values, which may be totally fine, depending on your situation. I did an inspiration using the mice package to generate a complete dataset for the starting values, and then substitute the data with missings back in for the actual estimating process.

For a subsequent analysis i used multinomial regression using a new function in the tidy sem package which allows you to include the class probabilities as uncertainty in the model via a logic akin to imputation.

Op ma 1 jul 2024 13:03 schreef C. J. van Lissa @.***>:

Dear @follhim https://github.com/follhim , unfortunately a lot of this just comes down to reading the documentation of OpenMx and tidySEM, and I can't give that kind of support! Maybe I'll record some instructional videos over the summer but can't promise anything

— Reply to this email directly, view it on GitHub https://github.com/cjvanlissa/tidySEM/issues/98#issuecomment-2199851169, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJAX3U5NRBQNFR7JIML5U5DZKEZQXAVCNFSM6AAAAABKCVNAECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJZHA2TCMJWHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

cjvanlissa commented 1 day ago

@Gootjes since you already did this, maybe we can turn it into a vignette? I would be happy to collaborate on that.

follhim commented 1 day ago

This is amazing-I would love if you could share your code!

Thank you so much!


Seungju Kim Wheaton College, BA 23'

On Mon, Jul 1, 2024 at 5:10 AM Gootjes @.***> wrote:

I wrote a similar analysis in R follhim! I can share the code with you. I did it slightly differently than CJ suggested, as his approach assumes MCAR for the starting values, which may be totally fine, depending on your situation. I did an inspiration using the mice package to generate a complete dataset for the starting values, and then substitute the data with missings back in for the actual estimating process.

For a subsequent analysis i used multinomial regression using a new function in the tidy sem package which allows you to include the class probabilities as uncertainty in the model via a logic akin to imputation.

Op ma 1 jul 2024 13:03 schreef C. J. van Lissa @.***>:

Dear @follhim https://github.com/follhim , unfortunately a lot of this just comes down to reading the documentation of OpenMx and tidySEM, and I can't give that kind of support! Maybe I'll record some instructional videos over the summer but can't promise anything

— Reply to this email directly, view it on GitHub https://github.com/cjvanlissa/tidySEM/issues/98#issuecomment-2199851169,

or unsubscribe < https://github.com/notifications/unsubscribe-auth/AJAX3U5NRBQNFR7JIML5U5DZKEZQXAVCNFSM6AAAAABKCVNAECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJZHA2TCMJWHE>

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/cjvanlissa/tidySEM/issues/98#issuecomment-2199978092, or unsubscribe https://github.com/notifications/unsubscribe-auth/AS5TO7QDLRBTUD63G5CGGKTZKFBKNAVCNFSM6AAAAABKCVNAECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJZHE3TQMBZGI . You are receiving this because you were mentioned.Message ID: @.***>

follhim commented 1 day ago

I hear you. If you do make a video please let me know!


Seungju Kim Wheaton College, BA 23'

On Mon, Jul 1, 2024 at 4:03 AM C. J. van Lissa @.***> wrote:

Dear @follhim https://github.com/follhim , unfortunately a lot of this just comes down to reading the documentation of OpenMx and tidySEM, and I can't give that kind of support! Maybe I'll record some instructional videos over the summer but can't promise anything

— Reply to this email directly, view it on GitHub https://github.com/cjvanlissa/tidySEM/issues/98#issuecomment-2199851169, or unsubscribe https://github.com/notifications/unsubscribe-auth/AS5TO7VCD644RTRLOEH5T7DZKEZQXAVCNFSM6AAAAABKCVNAECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJZHA2TCMJWHE . You are receiving this because you were mentioned.Message ID: @.***>