I want to use the command--sgmediation- to analyze the mediation of panel data.I read that --sgmediation--can not work for panel data.But I think that this command also works for panel data.
Here is my codes.Do you think it is right or wrong?
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(id year y x1 x2 x3) 1 1 3 2 7 3 1 2 2 1 6 4 1 3 3 2 6 5 1 4 4 2 5 6 1 5 5 3 4 7 2 1 6 4 5 8 2 2 5 3 6 8 2 3 5 3 5 7 2 4 4 2 4 6 2 5 3 3 5 5 3 1 4 5 6 4 3 2 5 6 7 3 3 3 6 7 8 6 3 4 5 8 8 7 3 5 4 6 7 8 3 6 3 4 6 9 4 1 6 5 5 8 4 2 5 6 4 7 4 3 6 7 3 6 4 4 7 7 . 5 4 5 8 6 2 4 4 6 9 5 4 3 end xi:sgmediation y,mv(x2) iv(x1) cv(x3 i.id i.year) i.id _Iid_1-4 (naturally coded; _Iid_1 omitted) i.year _Iyear_1-6 (naturally coded; _Iyear_1 omitted) Model with dv regressed on iv (path c) Source | SS df MS Number of obs = 21 -------------+---------------------------------- F(10, 10) = 2.63 Model | 41.4558892 10 4.14558892 Prob > F = 0.0718 Residual | 15.7822061 10 1.57822061 R-squared = 0.7243 -------------+---------------------------------- Adj R-squared = 0.4485 Total | 57.2380952 20 2.86190476 Root MSE = 1.2563 ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- x1 | 0.896 0.398 2.25 0.048 0.009 1.782 x3 | -0.170 0.164 -1.04 0.325 -0.534 0.195 _Iid_2 | 0.610 0.922 0.66 0.523 -1.445 2.664 _Iid_3 | -2.615 1.866 -1.40 0.191 -6.773 1.542 _Iid_4 | -0.291 1.857 -0.16 0.879 -4.429 3.846 _Iyear_2 | -0.542 0.889 -0.61 0.556 -2.524 1.439 _Iyear_3 | -0.379 0.937 -0.41 0.694 -2.466 1.707 _Iyear_4 | -0.223 1.005 -0.22 0.829 -2.462 2.016 _Iyear_5 | -0.155 0.910 -0.17 0.868 -2.184 1.873 _Iyear_6 | 1.724 1.254 1.37 0.199 -1.071 4.518 _cons | 2.717 1.254 2.17 0.056 -0.077 5.510 ------------------------------------------------------------------------------ Model with mediator regressed on iv (path a) Source | SS df MS Number of obs = 21 -------------+---------------------------------- F(10, 10) = 3.55 Model | 38.1930886 10 3.81930886 Prob > F = 0.0290 Residual | 10.7592924 10 1.07592924 R-squared = 0.7802 -------------+---------------------------------- Adj R-squared = 0.5604 Total | 48.952381 20 2.44761905 Root MSE = 1.0373 ------------------------------------------------------------------------------ x2 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- x1 | 0.307 0.328 0.94 0.372 -0.425 1.039 x3 | 0.014 0.135 0.11 0.918 -0.287 0.315 _Iid_2 | -0.933 0.761 -1.23 0.248 -2.629 0.763 _Iid_3 | 0.122 1.541 0.08 0.938 -3.310 3.555 _Iid_4 | -3.274 1.533 -2.14 0.059 -6.690 0.143 _Iyear_2 | 0.004 0.734 0.00 0.996 -1.632 1.640 _Iyear_3 | -0.484 0.773 -0.63 0.545 -2.207 1.239 _Iyear_4 | -0.843 0.830 -1.02 0.334 -2.691 1.006 _Iyear_5 | -1.407 0.752 -1.87 0.091 -3.082 0.267 _Iyear_6 | -0.353 1.036 -0.34 0.741 -2.660 1.955 _cons | 5.460 1.035 5.27 0.000 3.153 7.767 ------------------------------------------------------------------------------ Model with dv regressed on mediator and iv (paths b and c') Source | SS df MS Number of obs = 21 -------------+---------------------------------- F(11, 9) = 2.24 Model | 41.9107839 11 3.81007126 Prob > F = 0.1184 Residual | 15.3273113 9 1.70303459 R-squared = 0.7322 -------------+---------------------------------- Adj R-squared = 0.4049 Total | 57.2380952 20 2.86190476 Root MSE = 1.305 ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- x2 | -0.206 0.398 -0.52 0.618 -1.106 0.694 x1 | 0.959 0.431 2.23 0.053 -0.016 1.934 x3 | -0.167 0.170 -0.98 0.353 -0.551 0.218 _Iid_2 | 0.418 1.027 0.41 0.694 -1.906 2.741 _Iid_3 | -2.590 1.939 -1.34 0.214 -6.976 1.796 _Iid_4 | -0.964 2.328 -0.41 0.688 -6.229 4.301 _Iyear_2 | -0.542 0.924 -0.59 0.572 -2.631 1.548 _Iyear_3 | -0.479 0.992 -0.48 0.641 -2.722 1.765 _Iyear_4 | -0.397 1.096 -0.36 0.726 -2.877 2.084 _Iyear_5 | -0.445 1.099 -0.40 0.695 -2.931 2.041 _Iyear_6 | 1.651 1.311 1.26 0.239 -1.313 4.616 _cons | 3.839 2.533 1.52 0.164 -1.891 9.569 ------------------------------------------------------------------------------ Sobel-Goodman Mediation Tests Coef Std Err Z P>|Z| Sobel -.0631524 .13961254 -.4523 .65102373 Goodman-1 (Aroian) -.0631524 .19122088 -.3303 .74120433 Goodman-2 -.0631524 .04917211 -1.284 .19903234 Coef Std Err Z P>|Z| a coefficient = .307133 .328431 .93515 .349711 b coefficient = -.205619 .39785 -.516825 .605278 Indirect effect = -.063152 .139613 -.45234 .651024 Direct effect = .958806 .430893 2.22516 .02607 Total effect = .895654 .397774 2.25166 .024344 Proportion of total effect that is mediated: -.07050982 Ratio of indirect to direct effect: -.06586565 Ratio of total to direct effect: .93413435 tab id,gen(dum_id) id | Freq. Percent Cum. ------------+----------------------------------- 1 | 5 22.73 22.73 2 | 5 22.73 45.45 3 | 6 27.27 72.73 4 | 6 27.27 100.00 ------------+----------------------------------- Total | 22 100.00 . tab year,gen(dum_year) year | Freq. Percent Cum. ------------+----------------------------------- 1 | 4 18.18 18.18 2 | 4 18.18 36.36 3 | 4 18.18 54.55 4 | 4 18.18 72.73 5 | 4 18.18 90.91 6 | 2 9.09 100.00 ------------+----------------------------------- Total | 22 100.00 . bootstrap r(ind_eff) r(dir_eff), reps(500) : sgmediation y, mv(x2) iv(x1) cv(x3 dum_id* dum_year*) (running sgmediation on estimation sample) Bootstrap replications (500) ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 xxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxx.x.xx 50 xxxxx.xxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxx 100 xxxxxxxxx.xxxxxxxxxx.xx.xxxxxxxxx.xxx.xx.xxxxxx.xx 150 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 200 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxx. 250 xxxxxx.xxxxxxx.xx..xxxxxxxx.xxxxxxxxxx..xxxxxxxxxx 300 xxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 350 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 400 .xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxx 450 xxxxxxxxxx.xxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxx.x.x..x 500 Bootstrap results Number of obs = 21 Replications = 30 command: sgmediation y, mv(x2) iv(x1) cv(x3 dum_id* dum_year*) _bs_1: r(ind_eff) _bs_2: r(dir_eff) ------------------------------------------------------------------------------ | Observed Bootstrap Normal-based | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _bs_1 | -0.063 0.641 -0.10 0.921 -1.319 1.192 _bs_2 | 0.959 0.911 1.05 0.293 -0.828 2.745 ------------------------------------------------------------------------------ Note: One or more parameters could not be estimated in 470 bootstrap replicates; standard-error estimates include only complete replications.
Best
Raymond
0 Response to Panel data mediation use --sgmediation--
Post a Comment