coef.indirect: Extract the Indirect Effect or Conditional Indirect Effect

View source: R/coef_indirect.R

coef.indirectR Documentation

Extract the Indirect Effect or Conditional Indirect Effect

Description

Return the estimate of the indirect effect in the output of indirect_effect() or or the conditional indirect in the output of cond_indirect().

Usage

## S3 method for class 'indirect'
coef(object, ...)

Arguments

object

The output of indirect_effect() or cond_indirect().

...

Optional arguments. Ignored by the function.

Details

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.

Value

A scalar: The estimate of the indirect effect or conditional indirect effect.

See Also

indirect_effect() and cond_indirect().

Examples


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)


manymome documentation built on Oct. 4, 2024, 5:10 p.m.