Skip to contents

Return the conditional indirect effect of one row of the output of cond_indirect_effects().

Usage

get_one_cond_indirect_effect(object, row)

get_one_cond_effect(object, row)

Arguments

object

The output of cond_indirect_effects().

row

The row number of the row to be retrieved.

Value

An indirect-class object, similar to the output of indirect_effect() and cond_indirect(). See [indirect_effect)] and cond_indirect() for details on these classes.

[indirect_effect)]: R:indirect_effect) cond_indirect(): R:cond_indirect()

Details

It just extracts the corresponding output of cond_indirect() from the requested row.

Functions

  • get_one_cond_effect(): An alias to get_one_cond_indirect_effect()

Examples


library(lavaan)
dat <- modmed_x1m3w4y1
mod <-
"
m1 ~ x  + w1 + x:w1
m2 ~ m1
y  ~ m2 + x + w4 + m2:w4
"
fit <- sem(mod, dat,
           meanstructure = TRUE, fixed.x = FALSE,
           se = "none", baseline = FALSE)
est <- parameterEstimates(fit)

# Examples for cond_indirect():

# Conditional effects from x to m1
# when w1 is equal to each of the default levels
out1 <- cond_indirect_effects(x = "x", y = "m1",
                              wlevels = c("w1", "w4"), fit = fit)
get_one_cond_indirect_effect(out1, 3)
#> 
#> == Conditional  Effect   ==
#>                                             
#>  Path:               x -> m1                
#>  Moderators:         w1, w4                 
#>  Conditional Effect: 0.297                  
#>  When:               w1 = -0.710, w4 = 1.209
#> 
#> Computation Formula:
#>   (b.m1~x + (b.x:w1)*(w1))
#> Computation:
#>   ((0.46277) + (0.23380)*(-0.71006))

# Conditional Indirect effect from x1 through m1 to y,
# when w1 is equal to each of the levels
out2 <- cond_indirect_effects(x = "x", y = "y", m = c("m1", "m2"),
                              wlevels = c("w1", "w4"), fit = fit)
get_one_cond_indirect_effect(out2, 4)
#> 
#> == Conditional Indirect Effect   ==
#>                                                       
#>  Path:                        x -> m1 -> m2 -> y      
#>  Moderators:                  w1, w4                  
#>  Conditional Indirect Effect: 0.048                   
#>  When:                        w1 = -0.710, w4 = -0.902
#> 
#> Computation Formula:
#>   (b.m1~x + (b.x:w1)*(w1))*(b.m2~m1)*(b.y~m2 + (b.m2:w4)*(w4))
#> Computation:
#>   ((0.46277) + (0.23380)*(-0.71006))*(0.39883)*((0.42709) + (0.02570)*(-0.90228))
#> Coefficients of Component Paths:
#>   Path Conditional Effect Original Coefficient
#>   m1~x              0.297                0.463
#>  m2~m1              0.399                0.399
#>   y~m2              0.404                0.427
#>