楼主: 葫芦娃大王
27231 16

[回归分析求助] 如何用Stata做中介效应分析中的sobel检验? [推广有奖]

  • 9关注
  • 27粉丝

学科带头人

8%

还不是VIP/贵宾

-

威望
0
论坛币
-18578 个
通用积分
3095.9137
学术水平
54 点
热心指数
63 点
信用等级
36 点
经验
7470 点
帖子
1202
精华
0
在线时间
2149 小时
注册时间
2012-11-22
最后登录
2024-8-25

50论坛币
在中介效应分析中,最理想的结果是依次检验时,自变量对中介变量,中介变量对因变量的系数都显著。但是,有些时候,自变量对中介变量的系数以及中介变量对因变量的系数这两个系数,只有一个显著,而另外一个不显著,根据温忠麟等(2004)的研究,这个时候可以做Sobel检验来判断中介效应是否显著。那么在stata中该如何进行Sobel检验呢?是否有更好的判断中介效应存在性的检验?谢谢大家!

关键词:中介效应分析 中介变量 中介效应 效应分析 如何进行
磨刀不误砍柴工!
沙发
黃河泉 在职认证  发表于 2018-12-30 08:26:45 |只看作者 |坛友微信交流群
很不幸地,温老师并没有用 Stata/R (我前两天跟他请教过)。请看看 https://stats.idre.ucla.edu/stat ... ion-tests-in-stata/

使用道具

藤椅
黃河泉 在职认证  发表于 2018-12-30 08:27:44 |只看作者 |坛友微信交流群
很不幸地,温老师并没有用 Stata/R (我前两天跟他请教过)。请看看 https://stats.idre.ucla.edu/stat ... ion-tests-in-stata/

使用道具

板凳
葫芦娃大王 学生认证  发表于 2019-1-1 09:08:21 |只看作者 |坛友微信交流群
黃河泉 发表于 2018-12-30 08:27
很不幸地,温老师并没有用 Stata/R (我前两天跟他请教过)。请看看 https://stats.idre.ucla.edu/stata/faq/ ...
谢谢黄老师!祝您新年快乐!

使用道具

报纸
黃河泉 在职认证  发表于 2019-1-1 11:00:10 |只看作者 |坛友微信交流群
葫芦娃大王 发表于 2019-1-1 09:08
谢谢黄老师!祝您新年快乐!
谢谢,也祝你身体健康,心想事成!

使用道具

地板
陈晓佳 发表于 2019-6-26 18:00:42 |只看作者 |坛友微信交流群
黃河泉 发表于 2019-1-1 11:00
谢谢,也祝你身体健康,心想事成!
黄老师您的这个链接打开已经不存在了,可以麻烦再分享一次吗,谢谢您!

使用道具

7
黃河泉 在职认证  发表于 2019-6-27 07:04:37 |只看作者 |坛友微信交流群
陈晓佳 发表于 2019-6-26 18:00
黄老师您的这个链接打开已经不存在了,可以麻烦再分享一次吗,谢谢您!
我也找不到!

使用道具

8
陈晓佳 发表于 2019-6-28 09:36:05 |只看作者 |坛友微信交流群
黃河泉 发表于 2019-6-27 07:04
我也找不到!
Thank you all the same.

使用道具

9
路边的野猫 发表于 2019-11-20 19:54:08 |只看作者 |坛友微信交流群
可以使用stata的sgmediation语句

使用道具

10
spoonshen 发表于 2019-11-20 23:47:57 |只看作者 |坛友微信交流群
Example:
use https://stats.idre.ucla.edu/stat/data/hsbdemo, clear

sem (read <- math)(science <- read math)

Endogenous variables

Observed:  read science

Exogenous variables

Observed:  math

Fitting target model:

Iteration 0:   log likelihood = -2098.5822  
Iteration 1:   log likelihood = -2098.5822  

Structural equation model                       Number of obs     =        200
Estimation method  = ml
Log likelihood     = -2098.5822

-------------------------------------------------------------------------------
              |                 OIM
              |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
--------------+----------------------------------------------------------------
Structural    |
  read        |
         math |    .724807   .0579824    12.50   0.000     .6111636    .8384504
        _cons |   14.07254   3.100201     4.54   0.000     7.996255    20.14882
  ------------+----------------------------------------------------------------
  science     |
         read |   .3654205   .0658305     5.55   0.000     .2363951    .4944459
         math |   .4017207   .0720457     5.58   0.000     .2605138    .5429276
        _cons |    11.6155   3.031268     3.83   0.000     5.674324    17.55668
--------------+----------------------------------------------------------------
   var(e.read)|   58.71925   5.871925                      48.26811    71.43329
var(e.science)|    50.8938    5.08938                      41.83548    61.91346
-------------------------------------------------------------------------------
LR test of model vs. saturated: chi2(0)   =      0.00, Prob > chi2 =      .

estat teffects

Direct effects
------------------------------------------------------------------------------
             |                 OIM
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural   |
  read       |
        math |    .724807   .0579824    12.50   0.000     .6111636    .8384504
  -----------+----------------------------------------------------------------
  science    |
        read |   .3654205   .0658305     5.55   0.000     .2363951    .4944459
        math |   .4017207   .0720457     5.58   0.000     .2605138    .5429276
------------------------------------------------------------------------------


Indirect effects
------------------------------------------------------------------------------
             |                 OIM
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural   |
  read       |
        math |          0  (no path)
  -----------+----------------------------------------------------------------
  science    |
        read |          0  (no path)
        math |   .2648593   .0522072     5.07   0.000     .1625351    .3671836
------------------------------------------------------------------------------


Total effects
------------------------------------------------------------------------------
             |                 OIM
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural   |
  read       |
        math |    .724807   .0579824    12.50   0.000     .6111636    .8384504
  -----------+----------------------------------------------------------------
  science    |
        read |   .3654205   .0658305     5.55   0.000     .2363951    .4944459
        math |     .66658     .05799    11.49   0.000     .5529217    .7802384
------------------------------------------------------------------------------

    The total effect for math, .66658, is the effect we would find if there was no mediator in our model. It is significant with a z of 11.49. The direct effect for math is .4017207 which, while still significant (z = 5.58), is much smaller than the total effect. The indirect effect of math that passes through read is .2648593 and is also statistically significant.

    It is often easier to interpret these values by computing ratios and proportions as shown below.

proportion of total effect mediated = .2648593/.66658 = .3973406

ratio of indirect to direct effect = .2648593/.4017207 = .65931205

ratio of total to direct effect =  .66658/.4017207 =  1.6593121

    We see above that the proportion of the total effect that is mediated is almost .40 which is a respectable amount. The ratio of the indirect effect to the direct effect is about .66 or almost 2/3 the size of the direct effect. And finally, the total effect is about 1.66 times the direct effect.

Mediation with bootstrap standard errors and confidence intervals

    If you are uncomfortable with the standard errors and confidence intervals produced directly by sem, you can obtain the bootstrapped standard errors and confidence intervals in two ways. First, by using the vce(boostrap) option after your sem command. Or second, by writing a small program that runs both the sem command and the estat teffects and then bootstrapping this program.

    Let’s demonstrate the vce(boostrap) option. Here we will add the reps option and request 200 replications.

sem (read <- math)(science <- read math), vce(bootstrap,reps(200))
Bootstrap replications (200)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
..................................................    50
..................................................   100
..................................................   150
..................................................   200

Structural equation model                       Number of obs     =        200
Estimation method  = ml                         Replications      =        200
Log likelihood     = -2098.5822

-------------------------------------------------------------------------------
              |   Observed   Bootstrap                         Normal-based
              |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
--------------+----------------------------------------------------------------
Structural    |
  read        |
         math |    .724807   .0581262    12.47   0.000     .6108818    .8387321
        _cons |   14.07254   3.092117     4.55   0.000     8.012099    20.13297
  ------------+----------------------------------------------------------------
  science     |
         read |   .3654205   .0802203     4.56   0.000     .2081915    .5226495
         math |   .4017207   .0875101     4.59   0.000     .2302041    .5732373
        _cons |    11.6155   2.707368     4.29   0.000     6.309158    16.92184
--------------+----------------------------------------------------------------
   var(e.read)|   58.71925    5.93704                      48.16332    71.58871
var(e.science)|    50.8938   5.496477                      41.18471    62.89176
-------------------------------------------------------------------------------

    Adding this option provides us bootstrapped confidence intervals. You can now use estat teffects to obtain normal-based bootstrapped confidence intervals around the indirect effect.

estat teffects

Direct effects
------------------------------------------------------------------------------
             |   Observed   Bootstrap                         Normal-based
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural   |
  read       |
        math |    .724807   .0581262    12.47   0.000     .6108818    .8387321
  -----------+----------------------------------------------------------------
  science    |
        read |   .3654205   .0802203     4.56   0.000     .2081915    .5226495
        math |   .4017207   .0875101     4.59   0.000     .2302041    .5732373
------------------------------------------------------------------------------


Indirect effects
------------------------------------------------------------------------------
             |   Observed   Bootstrap                         Normal-based
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural   |
  read       |
        math |          0  (no path)
  -----------+----------------------------------------------------------------
  science    |
        read |          0  (no path)
        math |   .2648593   .0593311     4.46   0.000     .1485726    .3811461
------------------------------------------------------------------------------


Total effects
------------------------------------------------------------------------------
             |   Observed   Bootstrap                         Normal-based
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural   |
  read       |
        math |    .724807   .0581262    12.47   0.000     .6108818    .8387321
  -----------+----------------------------------------------------------------
  science    |
        read |   .3654205   .0802203     4.56   0.000     .2081915    .5226495
        math |     .66658   .0592669    11.25   0.000     .5504189    .7827411
------------------------------------------------------------------------------

    However, you can also write a program to perform the bootstrapping. This enables us to obtain both percentile-based and bias-corrected confidence intervals as well as normal-based confidence intervals. Here is the program that we a calling indireff.ado.

program indireff, rclass
  sem (read <- math)(science <- read math)
  estat teffects
  mat bi = r(indirect)
  mat bd = r(direct)
  mat bt = r(total)
  return scalar indir  = el(bi,1,3)
  return scalar direct = el(bd,1,3)
  return scalar total  = el(bt,1,3)
end

    So how do we know which elements of r(indirect), r(direct) and r(total) we need? We will use the sem command and then quietly run estat teffects followed by a matrix list to see the matrices of the coefficients.

sem (read <- math)(science <- read math)
quietly estat teffects

matrix list r(indirect)

r(indirect)[1,3]
         read:   science:   science:
            o.         o.           
         math       read       math
r1          0          0  .26485934

matrix list r(direct)

r(direct)[1,3]
         read:   science:   science:
         math       read       math
r1  .72480697  .36542052  .40172068

matrix list r(total)

r(total)[1,3]
         read:   science:   science:
         math       read       math
r1  .72480697  .36542052  .66658002

    We see that in each case the coefficient of interest is the third element.

    Now that we know the correct matrix elements, we will run indireff for 200 bootstrap replications. You may want to run more, say 2,000 to 5,000. We will then request the percentile and biased corrected confidence intervals.

set seed 358395

bootstrap r(indir) r(direct) r(total), reps(200): indireff

Bootstrap replications (200)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
..................................................    50
..................................................   100
..................................................   150
..................................................   200

Bootstrap results                               Number of obs     =        200
                                                Replications      =        200

      command:  indireff
        _bs_1:  r(indir)
        _bs_2:  r(direct)
        _bs_3:  r(total)

------------------------------------------------------------------------------
             |   Observed   Bootstrap                         Normal-based
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _bs_1 |   .2648593   .0545941     4.85   0.000     .1578569    .3718618
       _bs_2 |   .4017207   .0872965     4.60   0.000     .2306228    .5728186
       _bs_3 |     .66658   .0576837    11.56   0.000      .553522    .7796381
------------------------------------------------------------------------------

Mediation with multiple IVs

    What if you had multiple independent variables? You just need to have one equation for each IV predicting the mediator variable. Here is the symbolic model.

sem (MV <- IV1)(MV <- IV2)(DV <- MV IV1 IV2)

    For our example, we will use math and ses as our independent variables. We will keep the same mediator and dependent variable as before.

sem (read <- math)(read <- ses)(science <- read math ses) Endogenous variables



Mediation with multiple mediators

    In this section we will consider the case in which there are multiple mediator variables. This time there will be one equation for each mediator variable. The symbolic form of the mode looks like this.

sem (MV1 <- IV)(MV2 <- IV)(DV <- MV1 MV2 IV)

    For our example we will use read and write as the mediators. We will go back to a single independent variable, math.

sem (read <- math)(write <- math)(science <- read write math)

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-11-5 12:37