View source: R/coef_indirect.R
coef.indirect | R Documentation |
Return the estimate of
the indirect effect in the output of
indirect_effect()
or or the
conditional indirect in the output of
cond_indirect()
.
## S3 method for class 'indirect'
coef(object, ...)
object |
The output of
|
... |
Optional arguments. Ignored by the function. |
It extracts and returns the
element indirect
. in an object.
If standardized effect is requested
when calling indirect_effect()
or
cond_indirect()
, the effect
returned is also standardized.
A scalar: The estimate of the indirect effect or conditional indirect effect.
indirect_effect()
and
cond_indirect()
.
library(lavaan)
dat <- modmed_x1m3w4y1
mod <-
"
m1 ~ x + w1 + x:w1
m2 ~ x
y ~ m1 + m2 + x
"
fit <- sem(mod, dat,
meanstructure = TRUE, fixed.x = FALSE,
se = "none", baseline = FALSE)
est <- parameterEstimates(fit)
# Examples for indirect_effect():
# Inidrect effect from x through m2 to y
out1 <- indirect_effect(x = "x", y = "y", m = "m2", fit = fit)
out1
coef(out1)
# Conditional Indirect effect from x1 through m1 to y,
# when w1 is 1 SD above mean
hi_w1 <- mean(dat$w1) + sd(dat$w1)
out2 <- cond_indirect(x = "x", y = "y", m = "m1",
wvalues = c(w1 = hi_w1), fit = fit)
out2
coef(out2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.