我正在尝试使用同名 R 包中的“plspm”函数来评估 SEM。我有两个竞争模型:
型号 1:
A<-c(0,0,0)
B<-c(1,0,0)
C<-c(0,1,0)
sat_path=rbind(A,B,C)
innerplot(sat_path)
相对
型号 2:
A<-c(0,1,0)
B<-c(0,0,0)
C<-c(0,1,0)
sat_path=rbind(A,B,C)
innerplot(sat_path)
因此,差异仅在于 A 和 B 之间的箭头方向。
当我运行代码时(见下文),第一个模型(模型 1)返回答案,而第二个模型(模型 2)返回以下错误:
check_path(path_matrix) 中的错误:“path_matrix”必须是下三角矩阵
我的问题:为什么?我看不出第一个矩阵如何具有正确格式的任何逻辑,而第二个则不能。我对什么构成“下三角矩阵”感到困惑吗?下面是完整的代码和一些自己运行的数据。提前致谢!
#Some play data:
Xdat<-rep(c(1,1,0,0,1),300)
XX<-matrix(Xdat,ncol=3,byrow=TRUE)
colnames(XX)<-c("A","B","C")
XX<-as.data.frame(XX)
attach(XX)
### Model 1: ####
pf<-c(0,0,0)
pm<-c(1,0,0)
po<-c(0,1,0)
sat_path=rbind(pf,pm,po)
# plot diagram of path matrix
innerplot(sat_path)
# blocks of outer model
sat_blocks = list(which(names(XX)=="A"), which(names(XX)=="B"), which(names(XX)=="C"))
# vector of modes (reflective indicators)
sat_mod = rep("A", 3)
# apply plspm
satpls = plspm(XX, sat_path, sat_blocks, modes = sat_mod,
scaled = FALSE)
# plot diagram of the inner model
innerplot(satpls)
### Model 2: ####
A<-c(0,1,0)
B<-c(0,0,0)
C<-c(0,1,0)
sat_path=rbind(pf,pm,po)
# plot diagram of path matrix
innerplot(sat_path)
# blocks of outer model
sat_blocks = list(which(names(XX)=="A"), which(names(XX)=="B"), which(names(XX)=="C"))
# vector of modes (reflective indicators)
sat_mod = rep("A", 3)
# apply plspm
satpls = plspm(XX, sat_path, sat_blocks, modes = sat_mod,
scaled = FALSE)
# this ends in an error (or should...!)