【问题标题】:Continuous moderator and an interaction term with a latent variable in lavaan连续调节器和与 lavaan 中的潜在变量的交互项
【发布时间】:2021-03-12 08:19:52
【问题描述】:

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

#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)

【问题讨论】:

  • 什么是 SSMCOVID?它是潜变量还是显变量?
  • 这是一个清单变量。

标签: r r-lavaan


【解决方案1】:

由于您没有提供实际数据,我将使用 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


【讨论】:

  • 非常感谢您的回复!我在上面的例子中展示的潜在变量实际上是实际潜在变量的简化版本。实际的潜在变量是一个三级模型(TSO 模型的一个示例可以在 Jeffrey A. Ciesla、David A. Cole 和 James H. Steiger (2007) 扩展特征-状态-场合模型:内部的重要性-Wave Measurement Equivalence?,结构方程建模:多学科期刊,14:1,77-97,DOI:10.1080/10705510709336737)。我可以使用您提出的方法来处理这种潜在变量吗?
  • 是的,您可以...从两个潜在变量中的每一个中选择三个指标,并在 var1var2 参数中使用它们。这是产生潜在交互的方法(使用两个潜在变量)。
  • 当潜在变量和观察变量之间存在交互时,这是否也适用?
  • 这样的话,就更简单了...latentvariable:indicator,使用:操作符。我调整了我的答案。
  • 太好了,确实简单多了!出于某种原因,我认为不可能在 lavaan 中以这种方式制作交互术语。再次感谢您的帮助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-28
  • 1970-01-01
  • 2021-12-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多