Issue in R package Lavaan SEM modeling

53 Views Asked by At

I want to create a Structural Equation Model (SEM) using the lavaan package in R. However, I am facing some issues during the modeling process. I am working with microbiome data. Could you please assist me in overcoming these problems?

I have used following codes for the analysis.

library(lavaan)
library(semPlot)
m1b <-   '
  # regressions
    Dementia_AG ~ C_aerofaciens+C_stercoris-1
    Control_AG ~ O_formigenes+S_anginosus+C_perfringens+S_enterica-1
  # variance (optional)
    Dementia_AG ~~ Control_AG
'
fit1b <- sem(m1b, data=practice_data_for_SEM_analysis)

Warning messages: 1: In lav_model_estimate(lavmodel = lavmodel, lavpartable = lavpartable, : lavaan ERROR: initial model-implied matrix (Sigma) is not positive definite; check your model and/or starting parameters. 2: In lav_model_estimate(lavmodel = lavmodel, lavpartable = lavpartable, : lavaan ERROR: initial model-implied matrix (Sigma) is not positive definite; check your model and/or starting parameters. 3: In lav_model_estimate(lavmodel = lavmodel, lavpartable = lavpartable, : lavaan ERROR: initial model-implied matrix (Sigma) is not positive definite; check your model and/or starting parameters. 4: In lav_model_estimate(lavmodel = lavmodel, lavpartable = lavpartable, : lavaan ERROR: initial model-implied matrix (Sigma) is not positive definite; check your model and/or starting parameters. 5: In lavaan::lavaan(model = m1b, data = practice_data_for_SEM_analysis, : lavaan WARNING: Model estimation FAILED! Returning starting values.

cov(new_data)
          C_aerofaciens  C_stercoris  O_formigenes   S_anginosus C_perfringens

C_aerofaciens 1.245209e-03 2.544454e-05 -3.447328e-06 -8.998240e-07 2.428222e-06 C_stercoris 2.544454e-05 3.363217e-06 3.234814e-08 4.452791e-07 6.451469e-07 O_formigenes -3.447328e-06 3.234814e-08 6.365657e-08 7.443029e-08 8.227743e-08 S_anginosus -8.998240e-07 4.452791e-07 7.443029e-08 2.010881e-07 2.347277e-07 C_perfringens 2.428222e-06 6.451469e-07 8.227743e-08 2.347277e-07 3.409987e-07 S_enterica -3.235251e-07 6.897520e-08 1.862812e-08 3.260950e-08 4.855493e-08 Dementia_AG 7.433954e-03 3.536726e-04 9.849102e-06 5.291080e-05 8.932950e-05 Control_AG -2.998957e-03 1.523680e-04 5.693680e-05 9.224409e-05 1.157158e-04 S_enterica Dementia_AG Control_AG C_aerofaciens -3.235251e-07 7.433954e-03 -2.998957e-03 C_stercoris 6.897520e-08 3.536726e-04 1.523680e-04 O_formigenes 1.862812e-08 9.849102e-06 5.693680e-05 S_anginosus 3.260950e-08 5.291080e-05 9.224409e-05 C_perfringens 4.855493e-08 8.932950e-05 1.157158e-04 S_enterica 1.356335e-08 1.488484e-05 1.527568e-05 Dementia_AG 1.488484e-05 7.811294e-02 1.023256e-02 Control_AG 1.527568e-05 1.023256e-02 7.015494e-02

Thank You Rishikesh

0

There are 0 best solutions below