Lavaan SEM mediation model with binary mediator not converging (edit: solved)

204 Views Asked by At

Solved! The warning I got was because I was asking the model to constrain a path that it was not estimating to begin with. I have removed this and my problem is solved.

I am running a mediation model using Lavaan with a binary mediator, so I am using the DWLS estimator. The primary predictor variable is also binary (random exposure), the outcome is continuous and there is one continuous covariate. The covariance between the predictor and the covariate is constrained to 0.

When fitting the model I get these warnings:

Warning messages: 
1: In muthen1984(Data = X[[g]], wt = WT[[g]], ov.names = ov.names[[g]], : lavaan WARNING: trouble constructing W matrix; used generalized inverse for A11 submatrix 
2: In muthen1984(Data = X[[g]], wt = WT[[g]], ov.names = ov.names[[g]], : lavaan WARNING: trouble constructing W matrix; used generalized inverse for A11 submatrix.

I tried reading the paper the error refers to (https://link.springer.com/article/10.1007/BF02294210) but I struggle to understand it.

The real problem comes when I start constraining parameters and the model doesn't converge. Does anyone have an idea why this might be happening?

Warning messages:
1: In muthen1984(Data = X[[g]], wt = WT[[g]], ov.names = ov.names[[g]],  :
  lavaan WARNING: trouble constructing W matrix; used generalized inverse for A11 submatrix
2: In muthen1984(Data = X[[g]], wt = WT[[g]], ov.names = ov.names[[g]],  :
  lavaan WARNING: trouble constructing W matrix; used generalized inverse for A11 submatrix
3: In lavaan::lavaan(model = model2, data = df, ordered = "Mediator",  :
  lavaan WARNING:
    Model estimation FAILED! Returning starting values.

These are the model specifications:

model0<-"Mediator ~ c(aA, aB)*Exposure + Covariate
         Outcome ~ c(bA, bB)*Mediator + Covariate
         Outcome ~ c(cA, cB)*Exposure 
         indirectA:=aA*bA
         indirectB:=aB*bB
         totalA:=cA+(aA*bA)
         totalB:=cB+(aB*bB)
         Exposure ~~ c(vA, vB)*Covariate
         vA==0
         vB==0"
fit1 <- sem(model0,
            group = "Moderator",
            data = df,
            ordered="Mediator",
            test="scaled.shifted",
            estimator = "DWLS")

model1<-"Mediator ~ c(aA, aB)*Exposure + Covariate
         Outcome ~ c(bA, bB)*Mediator + Covariate
         Outcome ~ c(cA, cB)*Exposure 
         indirectA:=aA*bA
         indirectB:=aB*bB
         totalA:=cA+(aA*bA)
         totalB:=cB+(aB*bB)
         Exposure ~~ c(vA, vB)*Covariate
         vA==0
         vB==0
         aA==aB"
fit2 <- sem(model1,
            group = "Moderator",
            data = df,
            ordered="Mediator",
            test="scaled.shifted",
            estimator = "DWLS")

model2<-"Mediator ~ c(aA, aB)*Exposure + Covariate
         Outcome ~ c(bA, bB)*Mediator + Covariate
         Outcome ~ c(cA, cB)*Exposure 
         indirectA:=aA*bA
         indirectB:=aB*bB
         totalA:=cA+(aA*bA)
         totalB:=cB+(aB*bB)
         Exposure ~~ c(vA, vB)*Covariate
         vA==0
         vB==0
         bA==bB"
fit2 <- sem(model2,
            group = "Moderator",
            data = df,
            ordered="Mediator",
            test="scaled.shifted",
            estimator = "DWLS")

When I try to constrain the b path in the model, model estimation fails. I would not be surprised if the model was a worse fit, but I don't see any reason that it should not converge. Does anyone have an idea why this might be?

0

There are 0 best solutions below