Adding controls to moderated mediation model devtools/lavaan

Hi everyone,

I am new to this community and rather new to R so bear with me.

I have a question regarding a code for a moderated mediation model using devtools and lavaan. I ran:

´´´

download and load package

devtools::install_github("patc3-phd/gentleman")
library(gentleman)

moderated mediation model

mod_med1 <- get_moderated_mediation_model(x="x", m="m", y="y", mod_a="w", values_at=list(w=c(0,1)))

library(lavaan)
fit <- sem(mod_med1, df_med4, sampling.weights = "weight", estimator = "DWLS", bootstrap = 10000)
summary(fit, standardized = TRUE, fit.measures=TRUE)

parameterestimates(fit)

´´´´

....And it works well. However, I wonder if there's any way to extend the model to incorporate control variables (two categorical variables with three levels, and two binary variables). In other words; is it possible to add control variables to the get_moderated_mediation_model function?

X is a numerical likert-scale variable, Y is a binary categorical variable, W is a a numerical likert-scale variable (the dependent variable have been defined as ordered in advance as according to the lavaan instructions for mediation models).

Otherwise I guess I'll have to write the entire syntax using Lavaan only.

Thankful for any help regarding this!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.