连续调节器和 lavaan 中具有潜在变量的交互项

Continuous moderator and an interaction term with a latent variable in lavaan

我是 lavaan 的新用户,一直在尝试构建一个具有连续调节器和具有潜在变量的交互项的调节器模型。我想听听您对我的代码的反馈,尤其是 我的方法是否适合之后添加交互项(因为它需要在数据框中保存潜在变量)。简单介绍一下我的研究:我调查了压力和倦怠之间的关系,以及社会支持是否调节了这种关联。不幸的是,我还没有实际数据,所以我无法提供有关可能 warning/error 消息的信息。

#Creating the centered moderator variable SSMCOVID.c
Dataset$SSMCOVID.c <- scale(Dataset$SSMCOVID, scale = FALSE)

#Setting up the measurement model
RQ3 <- '
#Creating the independent TsM variable:
TsM =~ 1*SsM3mo + 1*SsM12mo + 1*SsM4y + 1*SsM4.5y

# Stress-burnout (independent-dependent):
PBAMCOVID ~ b1*TsM

#Support-burnout (moderator-dependent):
PBAMCOVID ~ b2*SSMCOVID.c '

fit.3 <- sem(RQ3, data = Dataset, estimator = 'MLR', missing = 'ML')
summary(fit.3, fit.measures=TRUE, standardized=TRUE)

#Extracting the predicted values of the model and adding them to the dataframe
data <- data.frame(Dataset, predict(fit.3))

#Creating a new variable with the interaction (note: dplyr package needed!)
data <- data %>%
              mutate(TsM_x_SSMCOVID.c = TsM * SSMCOVID.c)
              
#Testing the predefined interaction (moderation):
Moderation <- ' PBAMCOVID ~ b3*TsM_x_SSMCOVID.c '

fit.Mod <- sem(Moderation, data = data, estimator = 'MLR', missing = 'ML')
summary(fit.Mod, fit.measures=TRUE, standardized=TRUE)

由于您没有提供实际数据,我将使用 HolzingerSwineford1939 数据框制作一个示例。库 semTools 具有使用无中心化、均值中心化、双均值中心化或残差中心化来生成指标乘积的函数:

df_mod <- indProd(data = HolzingerSwineford1939, #create a new data.frame with the interaction indicators
                  var1 = paste0("x",c(1:3)), #interaction indicators from the first latent
                  var2 = paste0("x",c(4:6)), #interaction indicators from the second latent
                  match = T, #use match-paired approach (it produces the product of the first indicators of each variable, the product of the second indicator of each latent variable...
                  meanC = T, # mean centering the main effect indicator before making the products
                  residualC = T, #residual centering the products by the main effect indicators
                  doubleMC = T) #centering the resulting products

head(df_mod[,(ncol(df_mod)-2):ncol(df_mod)]) #check the last three columns of the new data.frame


model_latent_mod <- "
latent_mod =~  
x1.x4+
x2.x5+
x3.x6"

fit_lat_mod <- cfa(model = model_latent_mod, data = df_mod) #run your latent interaction measurement model
summary(object = fit_lat_mod, std=T, fit.m=T) #check the summary

然后您只需将此测量模型添加到您的结构模型中即可。这种方法对于在潜在变量之间产生相互作用很有用,我相信这应该是你的情况。

如果你想在潜在变量和显变量之间进行交互:


model_latent_manifest_inter <- "
latent_mod =~  
x1
x2
x3

ageyr ~latent_mod:x4
"

fit_lat_mod <- sem(model = model_latent_manifest_inter, data = HolzingerSwineford1939) #run your latent interaction measurement model
summary(object = fit_lat_mod, std=T, fit.m=T) #check the summary