It currently only support simple mediation analysis using the path analysis approach with the lavaan
package. I am trying to implement multilevel mediation in lavaan
.
In the future, I will try supporting moderated mediation (through lavaan
or mediation
) and mediation with latent variable (through lavaan
).
mediation_summary(
data,
response_variable,
mediator,
predictor_variable,
control_variable = NULL,
group = NULL,
standardize = TRUE,
digits = 3,
quite = FALSE,
streamline = FALSE,
return_result = FALSE
)
data.frame
response variable. Support dplyr::select()
syntax.
mediator. Support dplyr::select()
syntax.
predictor variable. Support dplyr::select()
syntax.
control variables / covariate. Support dplyr::select()
syntax.
nesting variable for multilevel mediation. Not confident about the implementation method.
standardized coefficients. Default is TRUE
number of digits to round to
suppress printing output
print streamlined output
If it is set to TRUE
, it will return the lavaan
object
an object from lavaan
mediation_summary(
data = lmerTest::carrots,
response_variable = Preference,
mediator = Sweetness,
predictor_variable = Crisp
)
#> Warning: The following columns are coerced into numeric: Consumer, Frequency, Gender, Age, Homesize, Work, Income, Product
#> Model Summary
#> Model Type = Mediation Analysis (fitted using lavaan)
#>
#> Effect Summary
#> ────────────────────────────────────────────────────────────────
#> Effect Type Est.Std SE z p 95% CI
#> ────────────────────────────────────────────────────────────────
#> direct 0.197 0.029 6.880 0.000 *** [0.141, 0.253]
#> indirect 0.219 0.017 12.656 0.000 *** [0.185, 0.253]
#> total 0.416 0.023 18.444 0.000 *** [0.372, 0.460]
#> ────────────────────────────────────────────────────────────────
#> *** p < 0.001, ** p < 0.01, * p < 0.05, + p < 0.1
#>
#> Regression Summary
#> ────────────────────────────────────────────────────────────────────────────────────
#> Response Operator Predict Est.Std SE z p 95% CI
#> ────────────────────────────────────────────────────────────────────────────────────
#> Sweetness ~ Crisp 0.558 0.018 30.893 0.000 *** [0.523, 0.593]
#> Preference ~ Sweetness 0.392 0.028 14.177 0.000 *** [0.338, 0.446]
#> Preference ~ Crisp 0.197 0.029 6.880 0.000 *** [0.141, 0.253]
#> ────────────────────────────────────────────────────────────────────────────────────
#> *** p < 0.001, ** p < 0.01, * p < 0.05, + p < 0.1
#> You can drag and resize the R console to view the entire table