Dear All
I am working on multiple dependent variables in my research (Mean1, Mean2, Median1, Median2, SD1, SD2, Range1 and Range2) and multiple interested variables (EM1, EM2... EM5) with others as control. What I am looking for is a macro for the OLS regressions (better if I can apply xtreg-fe but Pooled OLS is also acceptable).
If I apply separately they become 40 regressions, but I have to check the results industry-wise which will make it even more.
The code represents the industry which is from 1 to 18. This makes it huge number of estimations (40*18).
I'll divide my 18 industries into 5 broader industries. So total regressions will be (40*5) I have a macro to calculate residuals from the regressions.
In this macro, I can save the residuals as another variable. But I need to export my regression estimations to word or excel (for example with "outreg2") which I use normally to export my regression estimations.
I have data from 2006 to 2018, and I'll apply the same equations year-wise also for robustness.
I have panel data, I'll prefer to apply following equations:
xtreg Mean1 EM1 GW_w Log_AF_w AQ, fe
xtreg Mean1 EM2 GW_w Log_AF_w AQ, fe
xtreg Mean1 EM3 GW_w Log_AF_w AQ, fe
....
xtreg Range1 EM5 GW_w Log_AF_w AQ, fe
xtreg Range2 EM5 GW_w Log_AF_w AQ, fe
I'll be grateful for the help.
Thank you so much.
I am working on multiple dependent variables in my research (Mean1, Mean2, Median1, Median2, SD1, SD2, Range1 and Range2) and multiple interested variables (EM1, EM2... EM5) with others as control. What I am looking for is a macro for the OLS regressions (better if I can apply xtreg-fe but Pooled OLS is also acceptable).
If I apply separately they become 40 regressions, but I have to check the results industry-wise which will make it even more.
The code represents the industry which is from 1 to 18. This makes it huge number of estimations (40*18).
I'll divide my 18 industries into 5 broader industries. So total regressions will be (40*5) I have a macro to calculate residuals from the regressions.
Code:
gen EM1 = . forval y = 2006(1) 2018 { forval i = 1(1) 18 { display `i' display `y' capture reg ta ia rev ppe roa_w if `i' == code & `y' == Data_Year, noconstant predict r if `i' == code & `y' == Data_Year, residuals replace EM1 = r if `i' == code & `y' == Data_Year drop r } }
I have data from 2006 to 2018, and I'll apply the same equations year-wise also for robustness.
I have panel data, I'll prefer to apply following equations:
xtreg Mean1 EM1 GW_w Log_AF_w AQ, fe
xtreg Mean1 EM2 GW_w Log_AF_w AQ, fe
xtreg Mean1 EM3 GW_w Log_AF_w AQ, fe
....
xtreg Range1 EM5 GW_w Log_AF_w AQ, fe
xtreg Range2 EM5 GW_w Log_AF_w AQ, fe
I'll be grateful for the help.
Thank you so much.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str90 Name int Data_Year float(code VarA VarB VarC VarD VarV VarW VarX VarY VarZ) "Cleveland-Cliffs Inc" 2008 1 .007314365 .0041414485 .020833334 .012103175 .10562479 .10550115 .08748595 .05130406 .00616741 "Martin Marietta Materials, Inc." 2011 1 .0006838465 .0011484822 .0022766695 .0036860364 .00431976 .004146068 .03903709 .013373328 .01231557 "Reliance Steel & Aluminum Co." 2007 1 .001312138 .0003310818 .003047232 .000761808 .014071214 .01436755 .04775405 .013270291 .199774 "Steel Dynamics, Inc." 2013 1 .0017828114 .0012093955 .005521267 .0043699928 .00014757607 .0006846298 .10338589 .07516815 .07922927 "Trex Company, Inc." 2008 1 . .005756522 0 .014101057 .160646 .15282223 .12101376 .35309505 .29972965 "Trex Company, Inc." 2009 1 . .010557716 0 .02308627 .017786155 .020993756 .03904347 .1669213 .15347195 "Newmont Goldcorp Corporation" 2014 1 .006990013 .005285758 .02561876 .016846374 .05042892 .05042892 .07155451 .0838274 .0009181937 "Olympic Steel, Inc." 2013 1 .005208943 .0023200994 .009936766 .0045284103 .12434489 .12578458 .06810709 .14230484 .014565297 "Eagle Materials Inc." 2010 1 .001902687 .0035990786 .004990403 .00959693 .01868571 .01808794 .0100235 .05913265 .04824474 "Intrepid Potash, Inc." 2008 1 . . . . . . . . . "Universal Forest Products, Inc." 2008 1 . .004532485 0 .008486049 . .1602996 . . . "Hecla Mining Company" 2009 1 .012140715 .016342143 .02857143 .04285714 .02122286 .017641889 .06012893 .06484702 .004874679 "Hecla Mining Company" 2018 1 .006234509 .002963728 .017632242 .008640302 .007847334 .007832159 .007535768 .068581626 .0004522282 "Universal Stainless & Alloy Products, Inc." 2008 1 0 .0012572673 0 .0033736294 .006539847 .005198891 .01319312 .070619315 .04385194 "Stillwater Mining Company" 2012 1 .003357457 .005265392 .00669216 .00956023 .19961025 .19590746 .06574199 .036179017 .02118735 "AK Steel Holding Corporation" 2008 1 .004505926 .003114403 .01232699 .006641869 .006777993 .0038815176 .07708839 .02301766 .03923722 "Newmont Goldcorp Corporation" 2017 1 .003001115 .0007616965 .01144702 .003730555 .02550161 .02550161 .07472377 .0006131274 .0020647477 "Centrus Energy Corp. Class A" 2011 1 .00575401 . .009966245 0 .13227798 .131005 .05113817 .5765372 .15945767 "Martin Marietta Materials, Inc." 2006 1 .00018433263 .000488256 .00026068822 .0010427529 .05206846 .05212311 .07068195 .028122533 .014002886 "Allegheny Technologies Incorporated" 2011 1 .0028642805 .00197278 .006524103 .004711852 .03579346 .035871353 .0075533 .03105192 .012105514 "Eagle Materials Inc." 2011 1 .0015530974 .0016161416 .0042477874 .005309734 .0010207065 .0007526404 .024828777 .04176411 .031011954 "United States Steel Corporation" 2018 1 .005210173 .001943194 .016818983 .007666667 .00297336 .0010018662 .00021876296 .17257553 .11803274 "Cleveland-Cliffs Inc" 2016 1 .07849716 .02237658 .1577724 .03164557 .17791104 .17791104 .28307265 .915621 .1801423 "Vulcan Materials Company" 2011 1 .0040758564 .003391434 .019009016 .01217313 .013352424 .01359714 .004885084 .023958974 .0045577935 "Freeport-McMoRan, Inc." 2007 1 .015693342 .012745846 .05293379 .04127041 .012594676 .012214413 .018541103 .03688155 .007614363 "Century Aluminum Company" 2012 1 .013513514 .003621857 .032902468 .009400705 .02836696 .02386587 .0474715 .14760667 .12111983 "Coeur Mining, Inc." 2018 1 .015606266 .00054426666 .034666665 .0013333333 .017043274 .01694069 .065039024 .08080392 .011598625 "United States Steel Corporation" 2006 1 .0033503016 .006456106 .010193468 .016018307 .0898129 .08998773 .17430677 .0745559 .09816443 "Plum Creek Timber Company, Inc." 2008 1 .0034327975 .00027343613 .011946133 .0010043441 .005663008 .005483489 .04495467 .033001605 .004778083 "Plum Creek Timber Company, Inc." 2010 1 .000529661 .0010129502 .001059322 .0023834745 .016400533 .016520249 .05816429 .016376415 .011207675 "Stillwater Mining Company" 2007 1 .012455084 . .01761409 0 .018346937 .019318134 .015422214 .10333212 .024525767 "Coeur Mining, Inc." 2011 1 .014987408 .019278733 .0431918 .05490483 .011681123 .011909053 .14892949 .09523598 .002222735 "USG Corporation" 2011 1 .014421628 .017093465 .04575163 .04355318 .0422988 .04293296 .19899584 .18480822 .00566187 "Martin Marietta Materials, Inc." 2012 1 .003317067 .00035057685 .008884763 .0010608672 .02280906 .025697216 .005931193 .01884414 .0040207603 "USG Corporation" 2006 1 .018684564 .05492966 .02642396 .07768248 .12225649 .12219553 .4626012 .07003907 .0022973102 "Reliance Steel & Aluminum Co." 2010 1 .00023137436 .00009444702 .0004627487 .00023137436 .04032888 .04009766 .04086951 .16685323 .15424424 "AK Steel Holding Corporation" 2018 1 .00774894 .0003014134 .025274735 .0009342756 .00465685 .005793244 .1066571 .3081555 .10764918 "Ameron International Corporation" 2010 1 .0010028364 .020201387 .001418216 .028569177 .04011424 .04115713 .022011066 .0006731414 .03967829 "Materion Corporation" 2013 1 .0015676882 .004034872 .002715283 .009309542 .02177878 .02243969 .015412797 .12611231 .027418895 "Newmont Goldcorp Corporation" 2008 1 .004382654 .0025954945 .015154618 .00860127 .0010750918 .0030740476 .04022465 .05968561 .005657097 "Louisiana-Pacific Corporation" 2018 1 .0004819878 .00057574257 .000681645 .0015232293 .021256525 .022365784 .04574981 .06143338 .016112162 "Nucor Corporation" 2013 1 .0012098007 .0007537303 .0043269233 .002548656 .007131457 .007253895 .02968024 .07665715 .05528798 "USG Corporation" 2014 1 .004575828 .001365504 .011980268 .006694856 .012053106 .012053106 .02270603 .011867848 .011293518 "Texas Industries, Inc." 2011 1 .005564613 .0022549804 .014416776 .005679336 .017853808 .018222524 .019041553 .02496488 .0013097016 "Allegheny Technologies Incorporated" 2007 1 .00050478603 .0003102448 .0013233348 .0009925012 .008592853 .008585084 .016324759 .036621504 .007904793 "Allegheny Technologies Incorporated" 2009 1 .0034529574 .000670897 .008225617 .00195848 .08225874 .0845285 .0037360354 .1084991 .008636797 "Allegheny Technologies Incorporated" 2012 1 .00057372387 .0007349582 .001464435 .0018828452 .015299574 .016582219 .010117458 .029477507 .006138802 "Allegheny Technologies Incorporated" 2014 1 .00053985405 .003014931 .001403312 .008139209 .02803474 .02803474 .063748196 .030836675 .016627498 "Allegheny Technologies Incorporated" 2016 1 .014139555 .010324355 .03111111 .033777777 .06327355 .06327355 .12798665 .11692352 .034472086 "Allegheny Technologies Incorporated" 2015 1 .011505896 .012655508 .030503364 .03508772 .02429305 .02427498 .05710368 .07481599 .008141876 "AMCOL International Corporation" 2010 1 .0009309641 .013814145 .0021111893 .02392681 .02283108 .02216989 .00522129 .05714107 .065003194 "United States Steel Corporation" 2010 1 .005162064 .002547678 .011248186 .006610849 .07368182 .073514804 .12227437 .08058877 .07907628 "Louisiana-Pacific Corporation" 2009 1 .05890961 .029692307 .1577724 .12179487 .25102824 .25416258 .4508776 .719945 .15014602 "Hycroft Mining Corp." 2011 1 .003173204 .000622767 .008741924 .001900456 . . . . . "AMCOL International Corporation" 2008 1 .0007850125 .012106467 .001110186 .02553428 .03829551 .03941807 .03958168 .02110622 .06748166 "Newmont Goldcorp Corporation" 2009 1 .002604398 .0039732433 .008353808 .013022359 .04036589 .03867706 .06271149 .023963565 .009040574 "Martin Marietta Materials, Inc." 2013 1 .0007062262 .00028722952 .0013788715 .0009546033 .006246026 .00658763 .028177086 .01471826 .006674893 "Alcoa Corp." 2007 1 .008061202 .006977008 .03084083 .022659114 . . . . . "Plum Creek Timber Company, Inc." 2015 1 .0008794578 .0001652489 .0016358963 .00023369947 .030553803 .03055255 .04187749 .018009538 .002352195 "Cleveland-Cliffs Inc" 2010 1 .0043084836 .0020026905 .008244739 .005641137 .04511741 .04531208 .19545397 .1769039 .011734134 "Plum Creek Timber Company, Inc." 2012 1 .0003868162 .00005128556 .00054704596 .0001107768 .02139594 .023805944 .02420281 .007661303 .003825266 "Plum Creek Timber Company, Inc." 2009 1 .0004208981 .0005400115 .0012311457 .001515544 .029374 .028390596 .06136063 .033474863 .0002944621 "Reliance Steel & Aluminum Co." 2013 1 .000910934 .0008946699 .0012882447 .0020933978 .06258415 .06198277 .05476202 .09675956 .2110693 "Plum Creek Timber Company, Inc." 2007 1 .0003040151 .002474655 .000697616 .006524467 .02764391 .027609203 .05057447 .04922187 .000692235 "Louisiana-Pacific Corporation" 2011 1 .005591755 .0044552856 .013742072 .01147241 .0039799674 .0044987323 .0889353 .1190556 .029963315 "Alcoa Corp." 2017 1 .012830342 .0003739316 .04231588 .0010683761 .007891939 .007891939 .037131958 .021817103 .12937443 "Hycroft Mining Corp." 2009 1 .028018577 .014044072 .07114624 .03754941 . . . . . "Hycroft Mining Corp." 2010 1 .010033157 .0041844165 .02320955 .01193634 . . . . . "Hycroft Mining Corp." 2013 1 .001493528 .0004693661 .002987056 .0006637903 . . . . . "Intrepid Potash, Inc." 2010 1 .0008532396 .00020671923 .002399726 .000685636 .003566496 .0038297756 .04771035 .03147362 .01147243 "Materion Corporation" 2009 1 .002004324 .0003515723 .005503145 .0007861635 .00603448 .010619687 .24739134 .16024856 .1244687 "Steel Dynamics, Inc." 2016 1 .0031257975 .00057828764 .01201343 .0021980973 .00004238188 .00004238188 .00716775 .032763246 .026391037 "Newmont Goldcorp Corporation" 2015 1 .0038738095 .0008784127 .013761217 .0037037036 . . .13327986 .14526336 .034865923 "Universal Forest Products, Inc." 2006 1 . .0014251274 0 .00325793 .03197455 .031948388 .07478106 .003138797 .0045604385 "Cleveland-Cliffs Inc" 2011 1 .00965025 .007523548 .03700936 .037033714 .031298112 .031440206 .1768023 .14508837 .011284005 "AMCOL International Corporation" 2006 1 .002855507 .0044797272 .005360624 .006335283 .0002578796 .00025991668 .013709677 .0627176 .04592209 "Worthington Industries, Inc." 2013 1 .005541016 .0038073875 .013466718 .01038861 .0013178836 .001966385 .05792763 .04911598 .04625949 "Hecla Mining Company" 2015 1 .010685305 .0019157706 .02504767 .0035842294 .015495618 .01542296 .04999648 .08259333 .021378204 "Century Aluminum Company" 2016 1 .0020950227 .005985973 .0029626696 .011312217 .00270482 .00270482 .28307265 .14226645 .36027545 "AMCOL International Corporation" 2009 1 .003178186 .0028956085 .00620525 .006682578 .10161255 .0988169 .02864117 .04777022 .12716989 "Steel Dynamics, Inc." 2014 1 .004001382 .0007080348 .01432958 .003070624 .012503044 .012503044 .014757307 .072355084 .05682764 "U.S. Concrete, Inc." 2015 1 . . . . . . . . . "Kaiser Aluminum Corporation" 2013 1 .000229243 .0013202302 .00032420165 .003728319 .0043429616 .004858363 .02548564 .011922616 .06567974 "Plum Creek Timber Company, Inc." 2011 1 . 9.345795e-06 0 .00002643525 .009312583 .0092496285 .0528349 .010158318 .0040855333 "Horsehead Holding Corp" 2014 1 . .0021955583 0 .004935225 .04650009 .04650009 .06991137 .0762363 .04350283 "Nucor Corporation" 2007 1 .0009631175 .0008246981 .002378339 .0025084156 .033742458 .033729605 .01668966 .00545309 .036652837 "Vulcan Materials Company" 2010 1 .003432846 .0020751092 .008353902 .006960964 .0009580897 .0007044072 .001288043 .02764589 .0017912544 "Allegheny Technologies Incorporated" 2010 1 .0018352915 .0011138709 .004690641 .00290373 .015242755 .015019587 .03589129 .022847425 .008085343 "Olympic Steel, Inc." 2016 1 .01043981 .0011723662 .02085216 .00203057 .2669764 .2669764 .4626012 .5768494 .04680921 "Materion Corporation" 2018 1 . .00011880659 . .0002057613 .01953923 .020172434 .07826243 .010548856 .03883896 "Universal Stainless & Alloy Products, Inc." 2007 1 0 .0019425926 0 .003882915 .02043712 .01897307 .001325722 .0747315 .05138276 "Reliance Steel & Aluminum Co." 2017 1 .0005350264 .00023055066 .0009671863 .0007543375 .01287142 .01287142 .11161807 .12134644 .17099012 "Owens Corning" 2015 1 .001191399 .0001464954 .003942753 .0008377548 .08466628 .08471919 .05096756 .11211615 .08552352 "Eagle Materials Inc." 2008 1 .001926071 .00050419953 .004791432 .0011273957 .007099816 .009449316 .0430969 .006898833 .036163434 "Olympic Steel, Inc." 2014 1 .003714044 .00028909591 .006879434 .00057432713 .1734941 .1734941 .3750222 .035502866 .066999 "Vulcan Materials Company" 2017 1 .0005072473 .002762421 .00135837 .009428686 .010263328 .010263328 .01544043 .0001618925 .004006341 "Intrepid Potash, Inc." 2009 1 .0010350987 .0020688493 .002888782 .00847376 .03013006 .031460695 .02549603 .005951261 .005235144 "USG Corporation" 2018 1 .004916001 . .01063278 . .006044996 .005690409 .02016007 .016602477 .012522734 "Worthington Industries, Inc." 2009 1 . .006397278 0 .015426497 .04501201 .04815124 .16510406 .12790349 .064653315 "Steel Dynamics, Inc." 2008 1 .010969212 .002000403 .03155951 .007722008 .00956061 .00998947 .01976233 .1763609 .016426967 end