为什么 R 和 PROCESS 会呈现不同的中介模型结果(一个重要,另一个不重要)?
作为刚刚开始R的新来者,我对调解分析的结果感到困惑。
我的模型很简单:iv't1incivi',调解器't1envied',dv't2psrb'。我使用过程在SPSS中运行了相同的模型,但是结果在过程中并不重要。但是,间接效果在R中很重要。由于我对R不太熟悉,您能帮我看看我的代码是否有任何问题?并告诉我为什么结果在R中很重要,但在SPSS中却不重要。谢谢一堆!!!
我在R:
X预测M
apath <- lm(T1Envied~T1Incivi, data=dat)
summary(apath)
X和M中的代码预测
bpath <- lm(T2PSRB~T1Envied+T1Incivi, data=dat)
summary(bpath)
间接效果的引导
getindirect <- function(dataset,random){
d=dataset[random,]
apath <- lm(T1Envied~T1Incivi, data=d)
bpath <- lm(T2PSRB~T1Envied+T1Incivi, data=dat)
indirect <- apath$coefficients["T1Incivi"]*bpath$coefficients["T1Envied"]
return(indirect)
}
library(boot)
set.seed(6452234)
Ind1 <- boot(data=dat,
statistic=getindirect,
R=5000)
boot.ci(Ind1,
conf = .95,
type = "norm")`*PSRB as outcome*
As a newcomer who just gets started in R, I am confused about the result of the mediation analysis.
My model is simple: IV 'T1Incivi', Mediator 'T1Envied', DV 'T2PSRB'. I ran the same model in SPSS using PROCESS, but the result was insignificant in PROCESS; however, the indirect effect is significant in R. Since I am not that familiar with R, could you please help me to see if there is anything wrong with my code? And tell me why the result is significant in R but not in SPSS?Thanks a bunch!!!
My code in R:
X predict M
apath <- lm(T1Envied~T1Incivi, data=dat)
summary(apath)
X and M predict Y
bpath <- lm(T2PSRB~T1Envied+T1Incivi, data=dat)
summary(bpath)
Bootstrapping for indirect effect
getindirect <- function(dataset,random){
d=dataset[random,]
apath <- lm(T1Envied~T1Incivi, data=d)
bpath <- lm(T2PSRB~T1Envied+T1Incivi, data=dat)
indirect <- apath$coefficients["T1Incivi"]*bpath$coefficients["T1Envied"]
return(indirect)
}
library(boot)
set.seed(6452234)
Ind1 <- boot(data=dat,
statistic=getindirect,
R=5000)
boot.ci(Ind1,
conf = .95,
type = "norm")`*PSRB as outcome*
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的函数
getindirect
中,所有线性回归都应基于d
中新整理的数据。然而,有一行
错误地引用了变量
dat
,实际上不应在此函数中使用该变量。仅此一点就可以解释不一致的结果。In your function
getindirect
all linear regressions should be based on the freshly shuffled data ind
.However there is the line
that makes the wrong reference to the variable
dat
which should really not be used within this function. That alone can explain incoherent results.