Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Longitudinal Mediation Analysis with Binary DV

72 views
Skip to first unread message

Cantyo Dannis

unread,
Oct 3, 2024, 4:25:00 PM10/3/24
to lavaan

So, I am testing a longitudinal mediation analysis, and here is my model:

 

Screen Shot 2024-10-03 at 18.33.47.png

JOV and NFS are continuous variables, but SS is a binary variable (0 v 1). So, I put this script in R:

 

modelz <- '

# Autoregressive paths

T2_JoV.23_Tot ~ T1_JoV.23_Tot

T3_JoV.23_Tot ~ T2_JoV.23_Tot

T3_JoV.23_Tot ~ T1_JoV.23_Tot

 

T2_SNeed1_Tot ~ T1_SNeed1_Tot

T3_SNeed1_Tot ~ T2_SNeed1_Tot

T3_SNeed1_Tot ~ T1_SNeed1_Tot

 

T2_SS1_Prev_2 ~ T1_SS1_Prev_2

T3_SS1_Prev_2 ~ T2_SS1_Prev_2

T3_SS1_Prev_2 ~ T1_SS1_Prev_2

 

# Cross-lagged paths

T3_SNeed1_Tot ~ T2_JoV.23_Tot

T2_SS1_Prev_2 ~ T1_SNeed1_Tot

 

# intercorrelation for control

T1_SNeed1_Tot ~~ T1_JoV.23_Tot

T1_SS1_Prev_2 ~~ T1_SNeed1_Tot

T1_SS1_Prev_2 ~~ T1_JoV.23_Tot

 

T2_SNeed1_Tot ~~ T2_JoV.23_Tot

T2_SS1_Prev_2 ~~ T2_SNeed1_Tot

T2_SS1_Prev_2 ~~ T2_JoV.23_Tot

 

T3_SNeed1_Tot ~~ T3_JoV.23_Tot

T3_SS1_Prev_2 ~~ T3_SNeed1_Tot

T3_SS1_Prev_2 ~~ T3_JoV.23_Tot

 

# Direct effect of X on Y (c path)

T3_SS1_Prev_2 ~ c*T1_JoV.23_Tot

 

# Effect of X on M (a path)

T2_SNeed1_Tot ~ a*T1_JoV.23_Tot

 

# Effect of M on Y (b path)

T3_SS1_Prev_2 ~ b*T2_SNeed1_Tot

 

#label effects with :=

direct := a

indirect := a*b

total := c + (a*b)

'

 

Fitz1 <- sem(modelz, data = jov4_sem, ordered = c("T2_SS1_Prev_2", "T3_SS1_Prev_2"), estimator = "WLSMV")

summary(fitz1, standardized = TRUE, fit.measures = TRUE, rsquare = TRUE)

parameterEstimates(fitz1, standardized = TRUE)

 

But it always says this warning and when I print the summary, it does not show the SE, z-value, and p value. It also shows the same warning if I put T1_SS1_Prev_2 as the ordered variable.

 

Warning message:

In lavaan::lavaan(model = modelz, data = jov4_sem, ordered = c("T2_SS1_Prev_2",  :

  lavaan WARNING:

    the optimizer warns that a solution has NOT been found!

 

However, this is not a problem if I do not specify the ordered variables:

 

fitz2 <- sem(modelz, data = jov4_sem)

summary(fitz2, standardized = TRUE, fit.measures = TRUE, rsquare = TRUE)

 

I wonder what is wrong with the first model (i.e., fitz1), and if I can do the second approach (i.e., fitz2; without specifying which are the ordered variables and WLS estimator? Any idea how should I address this?

Cantyo Dannis

unread,
Oct 4, 2024, 5:21:09 AM10/4/24
to lavaan

Hello everyone. I am testing a longitudinal mediation analysis, and here is my model:

I wonder what is wrong with the first model (i.e., fitz1), and if I can do the second approach (i.e., fitz2; without specifying which are the ordered variables and WLS estimator? Do you have any idea how I should address this?

Yago Luksevicius de Moraes

unread,
Oct 4, 2024, 9:40:44 AM10/4/24
to lavaan
Hello.

I don't see anything wrong with model fitz1 and the warning simply says that it did not find a solution. This is not unusual, especially with complex models, models with ordinal variables, or when sample size is small. Some ways to try to fix the problem:
a) increase sample size
b) try to make the model simpler, e.g., add restrictions
c) change the optimizer (you can check the available optimizers in the help page of lavaan::lavOptions if I'm not mistaken.

Regarding the second approach, I'm currently doing a study about it and the preliminary results indicate that:
a) you can do that if your goal is to check the goodness-of-fit indices, especially when you have none or few binary items.
b) you cannot do that if your goal is to check the factor loadings and correlations (and I suppose regression coefficients). You always underestimate them.

Best,
Yago
Reply all
Reply to author
Forward
0 new messages