Reputation: 11441
The following mediation model comes from the lavaan tutorial.
Below I printed the model structure using semPaths
from the semPlot
package. But one paths appears to be missing.
set.seed(1234)
X <- rnorm(100)
M <- 0.5*X + rnorm(100)
Y <- 0.7*M + rnorm(100)
Data <- data.frame(X = X, Y = Y, M = M)
model <- ' # direct effect
Y ~ c*X
# mediator
M ~ a*X
Y ~ b*M
# indirect effect (a*b)
ab := a*b
# total effect
total := c + (a*b)
'
fit <- sem(model, data = Data)
summary(fit, standardized=TRUE)
The regression part of the results is:
Regressions:
Estimate Std.Err Z-value P(>|z|) Std.lv Std.all
Y ~
X (c) 0.036 0.104 0.348 0.728 0.036 0.028
M ~
X (a) 0.474 0.103 4.613 0.000 0.474 0.419
Y ~
M (b) 0.788 0.092 8.539 0.000 0.788 0.679
Plotting the model using semPaths
only displays two of the three regression paths. The X -> Y path is not displayed.
semPaths(fit, "std", edge.label.cex = 0.71)
Can someone explain why this is so or how I can add the missing path?
Upvotes: 1
Views: 1958
Reputation: 11
estimate for Y ~ X is 0.036 (P= 0.728). So the path is very faint but it's still there (you can also find 0.03 written over the path, which should ideally be 0.04 when you round off to the second decimal) if you hunt for it.
You should be happy, given your output, doesn't work out the same for the data I collect. This makes your interpretation that much simpler: no direct effect but only mediation effect. specify mediation/indirect (M~X * Y~M), direct (Y~X)and total (M~X * Y~M + Y~X)effects in the model to know how they are turning out in terms of 0.95 CI or p values.
You have got a pretty straightforward case here, cheers!
Upvotes: 1
Reputation: 31
Try this and let me know if it helps
semPaths(fit, title = FALSE,layout = "spring", whatLabels = "std", intercepts = FALSE, style = "ram")
Upvotes: 0