Hi there,
I have run some simple mediation models with a binary IV and with continuous covariate, mediator, and DV. Prior to learning about the lavaan package, I ran the model with the mediation package.
I've compared the results between both packages, and the results are nearly identical (e.g., same coefficient estimates), but the p-values for the indirect effect differ, even though the coefficient estimates are the same and the p-values for the other effects are the same.
I'm using the bootstrapping technique in both packages, and have tried running the code with varying randomization seeds as well as number of simulations. Regardless, the same pattern is persisting. Below is the code I'm using and results. Has anyone encountered a similar situation? Is there an additional specifier I need to be adding to calculated the indirect effect accurately in lavaan?
library(lavaan)
sem_model = '
att_neg ~ a*group + chi_beh_control
avs_rpm_epi ~ c*group + chi_beh_control + b*att_neg
direct := c
#indirect effect
indirect := a*b
#total effect
total := c + (a*b)
'
set.seed(567)
model_sem2 = sem(sem_model, data=nona_data, se="bootstrap", test="bootstrap", bootstrap=1000)
The code used in the Mediation package & output is below:
med_fit_avs_rpm_epi_na <- lm(att_neg ~ group + chi_beh_control, data = nona_data)
out_fit_avs_rpm_epi_na <- lm(avs_rpm_epi ~ group + chi_beh_control + att_neg, data = nona_data)
set.seed(567)
med_out_avs_rpm_epi_na <- mediate(med_fit_avs_rpm_epi_na, out_fit_avs_rpm_epi_na, boot = TRUE, treat = "group", mediator = "att_neg", sims = 1000)
summary(med_out_avs_rpm_epi_na)
the ACME, ADE, and total effect estimates are the same as from the lavaan package, but the p-value differs significantly.
(ACME = average causal mediation effects/indirect effects)
Thank you!