Dear Statalist,
I would like your help with the 'medeff' command.
First, I have an unbalanced panel with 200,000 observations.
When I run the 'medeff' with the complete data base, the Stata crashes and I get no results after the bootstrapping - I have also limited the simulations to 10 instead of 1000
However, when I limit the data base to 30,000 observations, the code runs through.
Command:
medeff (regress trucks d_monitoring1 Avgweighttonne Distancedrivenkm Odometervaluekm Avgspeedkmh) (regress fuelconskml d_monitoring1 trucks Avgweighttonne Distancedrivenkm Odometervaluekm Avgspeedkmh), mediate(trucks) treat(d_monitoring1) sims(1000) vce(bootstrap)
Variables:
Results:
medeff (regress trucks d_monitoring1 Avgweighttonne Distancedrivenkm Odometervaluekm Avgspeedkmh) (regress fuelconskml d_monitoring1 trucks Avgweighttonne Distancedrivenkm Od
> ometervaluekm Avgspeedkmh), mediate(trucks) treat(d_monitoring1) sims(1000) vce(bootstrap)
Using 0 and 1 as treatment values
(running regress on estimation sample)
Bootstrap replications (50)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
.................................................. 50
Linear regression Number of obs = 33,014
Replications = 50
Wald chi2(5) = 5823.39
Prob > chi2 = 0.0000
R-squared = 0.1245
Adj R-squared = 0.1244
Root MSE = 85.4977
----------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
trucks | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-----------------+----------------------------------------------------------------
d_monitoring1 | -59.68996 .9123676 -65.42 0.000 -61.47817 -57.90175
Avgweighttonne | -1.249686 .0406836 -30.72 0.000 -1.329424 -1.169948
Distancedrivenkm | .0007154 .0001107 6.46 0.000 .0004985 .0009323
Odometervaluekm | -.000063 2.50e-06 -25.22 0.000 -.0000679 -.0000581
Avgspeedkmh | .0047144 .0124216 0.38 0.704 -.0196315 .0290602
_cons | 303.1544 2.44563 123.96 0.000 298.3611 307.9477
----------------------------------------------------------------------------------
(running regress on estimation sample)
Bootstrap replications (50)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
.................................................. 50
Linear regression Number of obs = 33,014
Replications = 50
Wald chi2(6) = 51894.74
Prob > chi2 = 0.0000
R-squared = 0.6489
Adj R-squared = 0.6488
Root MSE = 0.3008
----------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
fuelconskml | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-----------------+----------------------------------------------------------------
d_monitoring1 | .0109973 .0035193 3.12 0.002 .0040996 .017895
trucks | .0002705 .0000164 16.52 0.000 .0002384 .0003026
Avgweighttonne | -.0330538 .0002299 -143.76 0.000 -.0335045 -.0326032
Distancedrivenkm | .0000175 7.68e-07 22.77 0.000 .000016 .000019
Odometervaluekm | -9.54e-07 1.85e-08 -51.55 0.000 -9.90e-07 -9.18e-07
Avgspeedkmh | .0007197 .0004319 1.67 0.096 -.0001268 .0015662
_cons | 3.636518 .0276707 131.42 0.000 3.582284 3.690751
----------------------------------------------------------------------------------
(32,014 missing values generated)
(32,014 missing values generated)
(32,014 missing values generated)
------------------------------------------------------------------------------------
Effect | Mean [95% Conf. Interval]
-------------------------------+----------------------------------------------------
ACME | -.0161522 -.0182105 -.0142628
Direct Effect | .0108793 .0042243 .017732
Total Effect | -.0052729 -.0113257 .0010802
% of Tot Eff mediated | 2.822564 -22.36484 21.19477
------------------------------------------------------------------------------------
I would like your help with the 'medeff' command.
First, I have an unbalanced panel with 200,000 observations.
When I run the 'medeff' with the complete data base, the Stata crashes and I get no results after the bootstrapping - I have also limited the simulations to 10 instead of 1000
However, when I limit the data base to 30,000 observations, the code runs through.
- Is there a way to run the 'medeff' with the entire data base?
- Do you suggest another method to have the mediation effect?
- How do I interpret the results from 'medeff'?
Command:
medeff (regress trucks d_monitoring1 Avgweighttonne Distancedrivenkm Odometervaluekm Avgspeedkmh) (regress fuelconskml d_monitoring1 trucks Avgweighttonne Distancedrivenkm Odometervaluekm Avgspeedkmh), mediate(trucks) treat(d_monitoring1) sims(1000) vce(bootstrap)
Variables:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double fuelconskml byte d_monitoring1 float trucks double(Avgweighttonne Distancedrivenkm Odometervaluekm Avgspeedkmh) 2.046196761756577 1 177 36.14212014401485 4760.62 823026.73 50.0049076389355 2.076086226775837 1 199 35.2987334724339 7112.360000000001 830139.09 51.53832187679271 2.0883324555943887 1 198 34.50393177285128 8723.8 838862.89 52.69931083781783 2.0339534318919394 1 197 35.38759871416966 8542.34 847405.23 52.31036054731886 2.0188938064549524 1 120 35.48843649043638 1560.08 796314.13 52.5825351796197 2.2398736838214575 1 141 31.89764655770776 9696.01 806010.14 54.61540844634081 1.8822567958935938 1 165 40.71896048434724 8280.01 814290.15 54.72567612969794 2.076823386594049 1 177 36.68906020847979 7595.940000000001 821886.09 51.97388512877825 1.8684989045236728 1 199 36.16660892629559 6379.13 828265.22 48.20713759422645 1.9857991284575172 1 198 41.80646047388743 6480.02 834745.24 50.73272106875906 2.053318145645763 1 197 41.70991937138558 7895.46 842640.7000000001 53.3998196437965 2.109778615346544 1 120 36.9266674486239 3324.99 791562.48 55.10601840555758 1.8968326335010006 1 141 40.73353486526811 8217.06 799779.54 53.30945395566769 2.1153203120324005 1 165 34.22486140218172 5301.31 805080.85 57.02820226263543 1.9021277561313996 1 177 38.14367879753576 5867.95 810948.8 55.36179089770268 1.845634217302612 1 199 41.94038775140424 7726.6 818675.4 55.071988595866 1.93145606586284 1 198 33.92710418695228 6418.75 825094.15 51.69601868506537 2.141632025138293 1 197 35.00964639297794 8505.77 833599.81 54.97919389821744 2.7913990334617975 1 120 31.26473778790734 3650.48 685231.8200000001 64.99338776761738 2.279752541186779 1 141 31.01604850535961 7753.37 692984.93 55.167004310643 2.421752853854634 1 165 31.8703858295387 6744.17 699728.84 58.23925120657065 2.3193162838254064 1 177 34.78475875977016 7304.13 707032.8200000001 56.5265866541123 2.3197217930867873 1 199 35.28367171312994 7297.52 714330.21 50.01584373304395 2.417144073755543 1 198 31.43627199300906 8628.31 722958.52 55.02982694842468 2.3940575775532986 1 197 32.0076991710799 6948.8 729907.22 53.79612007509532 2.277955963086126 1 165 29.30511885840647 2315.36 583481.68 51.00442410187061 2.257455346604768 1 177 28.369176251888 12049.8 595531.48 49.25254782276964 2.387384317599855 1 199 27.3881464878373 11840.71 607372.1900000001 48.84098528579383 2.269504840418279 1 198 25.53630764936358 10819.07 618191.13 48.66276101696821 2.331449353154169 1 197 25.24018289429143 10250.73 628441.86 51.28235387307063 2.5144451813047177 1 120 37.47543978277263 5649.38 700860.76 57.55260812107183 2.2297044828191286 1 141 39.53577512776831 4320.32 705180.99 54.90536304329407 2.0472204747045075 1 165 41.72786845211445 4913.8 710094.62 52.28930192962542 2.346767279607403 1 177 33.30748251329808 6350.54 716444.73 55.47467090496585 2.329918241725043 1 199 37.90589230664501 6169.74 722614.39 55.18290480224796 2.2046360917248253 1 198 36.55552342014277 7606.7 730221.01 55.54723441544216 2.312145066325951 1 197 36.47981094806252 7528.09 737749.09 55.81209198110294 2.042462308534575 1 120 32.57807207196593 6789.88 769674.38 55.27617772631884 1.935392338167555 1 141 34.20312926365642 10810.85 780485.23 55.63505836675996 2.0174539169207093 1 165 33.0631975831843 8940.69 789425.92 54.74785679294579 1.9373118551930402 1 177 34.79848184079946 7954.37 797380.13 54.62978606503898 1.9176897332611873 1 199 34.73059061059161 9569.08 806949.21 54.46674002959814 1.8015174395049909 1 198 35.96856844264907 8315.210000000001 815264.42 53.50833421218681 1.9477890501381412 1 197 34.13824452079643 7028.85 822293.27 54.79635324180345 1.0148980073104588 1 135 23.77148599743243 1721.47 539366.15 14.99650815851944 1.0326658738341077 1 152 20.30144602985723 4697.690000000001 544063.78 17.2272528171037 1.050609474538355 1 154 13.24766375080008 4687 553425.93 20.82234516086438 1.0526409126113803 1 166 19.15582205321625 5817.02 559242.64 19.20787640197974 1.1203148881766523 1 168 19.1259864439842 5064.91 564307.47 20.30975997433667 1.0346843264686794 1 161 17.8872393337191 2263.91 566571.02 15.19085500417512 1.049685945429878 1 159 9.921397045448018 1044.49 567615.35 19.05115213910788 1.0605254406385103 1 135 17.77290442389219 2455.53 546834.33 16.49285799576107 1.1517241379310346 1 152 20.06855177841141 5362.37 552196.7 17.5773787627702 1.257003108702234 1 158 17.99228892937229 5895.42 558092.03 22.07627432461108 1.33012542175021 1 166 16.47353155235893 3737.28 569984.0700000001 16.8164987625928 1.1995740985024403 1 168 19.92544683429264 3301 573284.96 16.48901481619208 1.3025268483890968 1 161 18.05294007009032 5210.42 578495.1 18.80452330827068 1.3099604500471935 1 159 15.31272516698273 2262.21 580757.31 18.42423940781496 1.0499064565750633 1 135 15.47577751906674 2525.34 592111 14.84504448015049 1.0365784126606745 1 152 18.07037141649659 4708.73 596819.67 15.37116467341974 1.2963616750024518 1 158 17.07800269665321 4494.46 601313.81 19.69826453776806 1.0392708731983522 1 154 17.76250358819419 3448.81 604762.25 15.37473809346905 1.0591894704277638 1 166 14.69241880323725 1883.08 606645.04 15.85506798950337 1.0887671338216351 1 168 16.93769157967596 2831.72 609476.24 15.1647833770685 1.007141033279428 1 161 15.97026088279289 2366.58 611842.3 10.57500335135618 .9938841806114972 1 135 21.28647220505827 2346.65 568717.25 14.66396575606403 1.2095239842581806 1 158 18.92469794992757 5273.96 574627.75 21.30699229362987 1.273329619011139 1 154 18.02834062840413 6582.07 581209.25 18.0993086570256 1.3548666448902695 1 166 16.63313821794613 3567.12 584776.23 16.32717327871291 1.2869493357065667 1 168 19.08849921791389 2429.4 587205.34 14.73750549759791 1.4289293997789 1 161 17.85779298794917 3296.04 590501.2000000001 20.11999002965668 1.3911024534500733 1 159 20.29905113368326 3349.26 593850.46 19.71373775589785 1.077545876448656 1 135 15.91721356706312 5762.78 628057.47 21.58867890364602 1.0523801744781671 1 152 15.97927636962235 8310.32 636367.79 22.24733779908861 1.1021316308304645 1 158 15.78134054110636 10699.56 647067.35 23.98659385701235 1.1022105266402729 1 154 16.88308431506536 10726.79 657793.55 23.10148600143575 1.113528332378767 1 166 16.46774766864925 6104.83 663897.42 19.55779534846469 1.0789912946713187 1 168 16.24600493105653 7446.68 671343.97 18.4040943681842 1.105485905568908 1 159 16.14036245725059 4848.02 683326.72 18.24028694722474 1.1144116533960626 1 135 15.77478575281168 6007.08 622488.7000000001 22.67488151658768 1.1315439963033864 1 152 15.35225087738949 8570.880000000001 631059.0700000001 22.81861243180522 1.1185847027332507 1 158 16.5129938922538 10213.26 641272.31 24.50522392635584 1.1184506685646045 1 154 15.0696108725044 11220.23 652492.46 24.61582920406672 1.1659017300441359 1 166 37.52657357633576 6490.47 658982.93 22.28062553637837 1.12695667577918 1 168 55.6808115254734 7506.85 666489.62 20.07917349292855 1.1754142698635264 1 161 36.08482491986738 9078.7 675568.3 21.93520242363392 1.1798249430107715 1 159 17.75100006719009 6102.09 681670.38 21.37794174462499 1.0878589953454458 1 135 15.93731854363746 6027.62 594115.12 22.1187819877049 1.0614565437432377 1 152 17.26992176463138 8211.12 602326.09 22.36065980516896 1.0848246937046755 1 158 18.23430768703363 10501.32 612826.91 21.93843618342406 1.1347057834296972 1 154 15.11290075002514 11335.62 624162.53 23.65698722954301 1.1403822010226201 1 166 16.73607407520279 7875.24 632037.7000000001 22.95120326212876 1.1177717413384178 1 161 16.57390835714644 7978.8 646755.93 19.83778198915968 1.2620648768664742 1 159 13.62520743432334 6514.110000000001 653269.77 23.32597868804029 1.0246518851057722 1 135 12.49571212661538 2355.48 586980.0700000001 17.3795545936374 1.099588989155987 1 152 18.53514552822428 3625.07 590604.98 15.10961728831025 1.2451823319528694 1 158 19.34805801118826 4386.74 594991.59 20.12835435100143 1.39110638205937 1 154 19.65528398465053 7726.650000000001 602718.21 22.85649253645494 .8356100148726352 1 168 19.06875109823772 1764.19 605238.4400000001 7.423679482698766 1.2744691629637135 1 161 19.48064661937632 4402.59 609641.03 18.25340725606765 end
Results:
medeff (regress trucks d_monitoring1 Avgweighttonne Distancedrivenkm Odometervaluekm Avgspeedkmh) (regress fuelconskml d_monitoring1 trucks Avgweighttonne Distancedrivenkm Od
> ometervaluekm Avgspeedkmh), mediate(trucks) treat(d_monitoring1) sims(1000) vce(bootstrap)
Using 0 and 1 as treatment values
(running regress on estimation sample)
Bootstrap replications (50)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
.................................................. 50
Linear regression Number of obs = 33,014
Replications = 50
Wald chi2(5) = 5823.39
Prob > chi2 = 0.0000
R-squared = 0.1245
Adj R-squared = 0.1244
Root MSE = 85.4977
----------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
trucks | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-----------------+----------------------------------------------------------------
d_monitoring1 | -59.68996 .9123676 -65.42 0.000 -61.47817 -57.90175
Avgweighttonne | -1.249686 .0406836 -30.72 0.000 -1.329424 -1.169948
Distancedrivenkm | .0007154 .0001107 6.46 0.000 .0004985 .0009323
Odometervaluekm | -.000063 2.50e-06 -25.22 0.000 -.0000679 -.0000581
Avgspeedkmh | .0047144 .0124216 0.38 0.704 -.0196315 .0290602
_cons | 303.1544 2.44563 123.96 0.000 298.3611 307.9477
----------------------------------------------------------------------------------
(running regress on estimation sample)
Bootstrap replications (50)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
.................................................. 50
Linear regression Number of obs = 33,014
Replications = 50
Wald chi2(6) = 51894.74
Prob > chi2 = 0.0000
R-squared = 0.6489
Adj R-squared = 0.6488
Root MSE = 0.3008
----------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
fuelconskml | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-----------------+----------------------------------------------------------------
d_monitoring1 | .0109973 .0035193 3.12 0.002 .0040996 .017895
trucks | .0002705 .0000164 16.52 0.000 .0002384 .0003026
Avgweighttonne | -.0330538 .0002299 -143.76 0.000 -.0335045 -.0326032
Distancedrivenkm | .0000175 7.68e-07 22.77 0.000 .000016 .000019
Odometervaluekm | -9.54e-07 1.85e-08 -51.55 0.000 -9.90e-07 -9.18e-07
Avgspeedkmh | .0007197 .0004319 1.67 0.096 -.0001268 .0015662
_cons | 3.636518 .0276707 131.42 0.000 3.582284 3.690751
----------------------------------------------------------------------------------
(32,014 missing values generated)
(32,014 missing values generated)
(32,014 missing values generated)
------------------------------------------------------------------------------------
Effect | Mean [95% Conf. Interval]
-------------------------------+----------------------------------------------------
ACME | -.0161522 -.0182105 -.0142628
Direct Effect | .0108793 .0042243 .017732
Total Effect | -.0052729 -.0113257 .0010802
% of Tot Eff mediated | 2.822564 -22.36484 21.19477
------------------------------------------------------------------------------------
Comment