You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用R语言seminr包构建形成性PLS-SEM经济发展指数遇错求助

排查seminr包构建高阶形成性PLS-SEM模型的代码问题

问题场景

使用R语言seminr包构建形成性PLS-SEM模型以创建经济发展指数,模型包含Education、Health、Infrastructure、Employment 4个一阶潜变量(各对应3个指标),计划通过two-stage方法构建高阶复合指数Economic_Development,但模型估计时出现错误。

代码问题排查与修正

核心问题1:重复定义路径引发冲突

在seminr中,使用higher_composite定义高阶复合变量时,已经自动建立了一阶潜变量到高阶变量的形成性关系,无需再在structural_model的relationships中手动添加该路径,重复定义会导致模型逻辑冲突,触发错误。

核心问题2:形成性模型的权重模式错误

若一阶潜变量为形成性(即指标构成潜变量,而非潜变量反映指标),应使用mode_A权重模式;mode_B适用于反映性模型,与形成性模型的设定不符,会导致估计结果偏差。

修正后的完整代码

# 加载包并生成模拟数据
library(MASS)
library(seminr)

set.seed(123)
n <- 100

# 3个指标的相关矩阵
cor_matrix_3 <- matrix(c(1, 0.5, 0.5,
                         0.5, 1, 0.5,
                         0.5, 0.5, 1), nrow = 3)

# 生成各维度的相关数据
education <- mvrnorm(n, mu = c(5, 5, 5), Sigma = cor_matrix_3)
health <- mvrnorm(n, mu = c(4, 4, 4), Sigma = cor_matrix_3)
infrastructure <- mvrnorm(n, mu = c(6, 6, 6), Sigma = cor_matrix_3)
employment <- mvrnorm(n, mu = c(3, 3, 3), Sigma = cor_matrix_3)

# 构建数据集
data <- data.frame(
  education1 = education[,1],
  education2 = education[,2],
  education3 = education[,3],
  health1 = health[,1],
  health2 = health[,2],
  health3 = health[,3],
  infrastructure1 = infrastructure[,1],
  infrastructure2 = infrastructure[,2],
  infrastructure3 = infrastructure[,3],
  employment1 = employment[,1],
  employment2 = employment[,2],
  employment3 = employment[,3]
)

# 定义测量模型:一阶形成性复合 + 高阶two-stage复合
model <- constructs(
  # 一阶形成性复合,使用mode_A权重
  composite("Education", multi_items("education", 1:3), weights = mode_A),
  composite("Health", multi_items("health", 1:3), weights = mode_A),
  composite("Infrastructure", multi_items("infrastructure", 1:3), weights = mode_A),
  composite("Employment", multi_items("employment", 1:3), weights = mode_A),
  # 高阶复合,two-stage方法,形成性权重mode_A
  higher_composite("Economic_Development", 
                   c("Education", "Health", "Infrastructure", "Employment"), 
                   method = "two-stage", weights = mode_A)
)

# 结构模型:由于高阶复合已自动关联一阶变量,此处无需额外路径(空结构)
structure <- relationships()

# 估计PLS模型
adjusted_model <- estimate_pls(
  data = data,
  measurement_model = model,
  structural_model = structure
)

# 查看模型结果
summary(adjusted_model)
plot(adjusted_model)

补充说明

  • 若你的一阶潜变量实际为反映性(潜变量影响指标),则保留mode_B即可,但仍需删除结构模型中手动添加的一阶到高阶路径。
  • two-stage方法会先估计一阶复合变量的得分,再用这些得分估计高阶复合变量的权重,符合高阶指数构建的常规逻辑。

内容的提问来源于stack exchange,提问作者Velton Sousa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 02:38:10