I am working on multiple dependent variables in my research (Mean1, Mean2, Median1, Median2) and multiple interested variables (EM1, EM2... EM5) with others as control.
What I am looking for is a loop (macro) for the OLS regressions (better if I can apply xtreg-fe). If I apply separately they become 20 regressions, which is fine with me, but I have to check the results industry-wise. The code represents the industry which is from 1 to 18. This makes it huge number of estimations (20*18) and it will take huge time to do it separately.
I'll probably divide my 18 industries into 5 or 6 broader industries if need be in order to minimize the number of tables and explanation. But still, I'll require a loop to do it.
I have a loop 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 sales ppe 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, I'll also need to apply the same loop for year-wise results.
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 Mean4 EM5 GW_w Log_AF_w AQ, fe
Maybe I am asking too much, but I have been trying to use varlists for interested variables but to no avail.
I probably miss the code to estimates coefficients and also "est store" for outreg2.
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 Mean1 Mean2 Median1 Median2 EM1 EM2 EM3 EM4 EM5 GW_w Log_AF_w AQ) "3Com Corp" 2006 12 .063745834 .08969723 .069065 .09025278 .3353706 .3401662 .022446906 .08611465 .26383388 . .845098 1 "3D Systems Corporation" 2006 3 .039646 .00020166667 .0490905 .00020166667 .010358416 .010358778 .04292437 .016998366 .03817476 . .60206 0 "3M Company" 2006 2 .007902322 .008422193 .00789471 .008539871 .0016603 .0016603 .035717938 .09093802 .05108693 0 1.1139433 1 "4Kids Entertainment Inc." 2006 10 .010503505 .004155513 .010503505 .004155513 .11347649 .1134818 .01912983 .19080473 .04499265 . .60206 0 "51job Inc Sponsored ADR" 2006 12 .0009983673 .0021634013 .0009983673 .0007284353 . .016515575 . . . . .69897 1 "99 Cents Only Stores LLC" 2006 15 .0008692161 .00002581262 .0005038241 .00002581262 .029031867 .02903897 .03870155 .09156657 .17091577 0 .9542425 0 "A. O. Smith Corporation" 2006 2 .005301367 .0010280343 .005301367 .0010282052 .034765936 .034765936 .04028649 .09316947 .067026585 . .60206 1 "A.C. Moore Arts & Crafts Inc." 2006 15 .036451545 .018925773 .035764262 .018238489 . . .007290685 .26729378 .22543505 . .845098 1 "AAR CORP." 2006 3 .0082943635 .008225052 .0082943635 .009338205 .019813614 .019812576 .1488607 .15115064 .13475832 0 .60206 1 "ACADIA Pharmaceuticals Inc." 2006 7 .011662944 .0005197969 .011662944 .0005197969 . . .08196346 .009555575 .0783519 . .7781513 1 "ACCO Brands Corporation" 2006 2 .04396898 .03915094 .04396898 .0394151 .0593034 .0593034 .017244417 .06825052 .1405039 . .7781513 1 "ADTRAN, Inc." 2006 3 .0006654325 .00021844497 .00011881522 .0008909458 .04019183 .04019122 .031398762 .07464778 .016282605 0 1.39794 1 "AES Corporation" 2006 17 .05532786 .019089956 .05532786 .029061086 .09614318 .10468539 .24851057 .11336302 .03961832 0 .4771213 1 "AGCO Corporation" 2006 2 .1046898 .10942003 .10348582 .11072782 .08909133 .08909133 .01504703 .3123664 .18767384 .1134485 .9542425 1 "AGL Resources, Inc." 2006 17 .0017799484 .00051364553 .0017799484 .0003435794 . .015080176 . . . 0 .9542425 1 "AK Steel Holding Corporation" 2006 1 .0968668 .1045044 .0968668 .09758616 .28564572 .28540996 .175614 .5961582 .17019865 . .7781513 1 "AMCOL International Corporation" 2006 1 .007753898 .005723197 .008890838 .005723197 .0002578796 .00025991668 .013709677 .0627176 .04592209 . .60206 1 "AMERIGROUP Corp." 2006 13 .02601439 .029040596 .02581449 .03623484 .06139613 .06048205 .09219145 .9919918 .16714327 . 1.1139433 1 "AMETEK, Inc." 2006 2 .00510536 .0008933388 .0015401765 .0008933388 .0014094176 .0014094176 .02799903 .02224926 .0016821377 0 .9542425 1 "AMN Healthcare Services, Inc." 2006 10 .006496815 .004845298 .006159757 .0041375128 .066175915 .066122316 .02200506 .024535114 .06451668 . .7781513 1 "AMR Corporation" 2006 16 . . . . . . . . . . 1.1139433 . "ANADIGICS, Inc." 2006 3 .00006333333 .0134215 .00006333333 .02827 .0033890824 .0033884794 .0651138 .05223799 .05013228 . .7781513 0 "ANN INC." 2006 15 .002789108 .00011906141 .0024904404 .0009858054 .016314298 .016308902 .06660973 .242437 .21606283 . 1.146128 1 "ANSYS, Inc." 2006 12 .029292107 .03169314 .029292107 .031283204 .04198874 .04181831 .03629373 .05596795 .04003551 . .4771213 1 "ARC Document Solutions, Inc." 2006 10 .006465564 .006688311 .006229437 .006622983 .0021953562 .0021908 .05438123 .0710371 .01616997 . .7781513 1 "ARCA biopharma, Inc." 2006 7 .11017182 .05341983 .10365918 .031525895 .09848981 .09509923 .04363319 .0006385153 .25683162 . 1.1139433 1 "ARIAD Pharmaceuticals, Inc." 2006 7 .004788034 .00034017095 .006323077 .00034017095 . . .09726693 .0008982293 .08024678 . .90309 1 "ARO Liquidation Inc" 2006 15 .007448754 .00537814 .007659469 .004617754 . . .067123644 .03791776 .015369208 . 1.0791812 1 "ARRIS International Plc" 2006 3 .0355755 .029427666 .034941923 .028606126 .0259518 .0259518 .03977637 .028333677 .025074935 . 1.1139433 1 "ASGN Inc" 2006 10 .015050412 .007946838 .014821265 .010696609 .0079061175 .007905479 .0079972 .02585841 .013698236 . .60206 1 "AT&T Inc." 2006 18 .015916701 .017581053 .017069008 .018174766 .06036947 .06036122 .09999097 .02315538 .013756853 0 1.4313638 1 "ATC Technology Corp." 2006 10 .012978395 .008944444 .012978395 .017307613 .013242908 .01324255 .06477188 .10156827 .12302297 .034421563 .60206 1 "ATMI, Inc." 2006 3 .002423311 .0017407937 .0023632464 .0009821237 .06914056 .06914018 .033072233 .05772484 .031715818 . 1.1139433 1 "ATP Oil & Gas Corporation" 2006 5 .06368063 .04976566 .05971792 .04796433 .05432605 .05462154 .17514995 .06215892 .019381385 . .90309 1 "AVX Corporation" 2006 3 .0027154696 .0002983425 .001679558 .0002983425 .009438043 .009437492 .03822851 .05002636 .07471983 . 1 1 "Abbott Laboratories" 2006 7 .0020423536 .0022077097 .0019982248 .0022409332 .017307993 .01441201 .008523734 .001526888 .0014174127 0 1.20412 1 "Abercrombie & Fitch Co. Class A" 2006 15 .002999233 .003125959 .003140994 .003140994 .007380357 .007377262 .06383091 .21626966 .15365125 0 1.3222193 1 "Accuride Corp." 2006 2 . . . . . . . . . . .69897 . "Achieve Life Sciences, Inc." 2006 7 .5601432 .4972443 .5508934 .50053257 . .04854935 . . .13645296 . .4771213 1 "Achillion Pharmaceuticals, Inc." 2006 7 . . . . . . . . . . .60206 1 "Acme Packet Inc." 2006 3 . . . . . . . . . . .60206 1 "Acorda Therapeutics, Inc." 2006 7 . . . . . . . . . . .4771213 1 "Actel Corp" 2006 3 .04811862 .019053416 .04811862 .019053416 .018702736 .018702466 .032410998 .16799948 .18772274 . .4771213 1 "Actions Semiconductor Co. Ltd. Sponsored ADR" 2006 3 .0008838384 .0003185606 .0008838384 .0003787879 .02050263 .02050313 .0818862 .03367301 .05078882 . .69897 1 "Activision Blizzard, Inc." 2006 4 .011852693 .00012649198 .012020378 .0011033479 .0033856966 .003385776 .01328034 .02398733 .0410225 . 1.3802112 1 "Actuate Corporation" 2006 12 .0011210191 .006694268 .0011210191 .0004713376 .13689885 .13549544 .034533117 .19616683 .15858184 . .4771213 1 "Acusphere, Inc." 2006 7 .05799625 .00005617978 .06174157 .00005617978 . . .14485614 .0009687925 .14423145 . .60206 1 "Adhera Therapeutics Inc" 2006 7 .001896739 .0006484375 .0037649455 .0007078805 .06124213 .06329253 .004983284 .02227352 .06503258 . .60206 1 "Adolor Corp" 2006 7 .002802055 .0039849314 .0041719177 .00006232877 .08451973 .08276392 .07157366 .01156879 .08169235 . .90309 1 "Advance Auto Parts, Inc." 2006 15 .0004622642 .0005421077 .0004507593 .0004507593 .01123649 .011240565 .018033704 .1780962 .16838704 0 1.146128 1 "Advanced Analogic Technologies" 2006 3 .0021696752 .005057762 .0021696752 .0014476535 .065107785 .06510771 .002738742 .01973288 .017304847 . .845098 1 "Advanced Emissions Solutions, Inc." 2006 2 .00312721 .0001622816 .00312721 .0001622816 .028356556 .028356556 .05278634 .010711684 .036591385 . .4771213 0 "Advanced Energy Industries, Inc." 2006 3 .04214032 .030051563 .04214032 .042224 .1027748 .1027758 .08481114 .13497742 .02244539 . 1.0413927 0 "Advanced Micro Devices, Inc." 2006 3 .04386372 .034011602 .04432745 .03419673 .10501678 .10501494 .04971675 .05034883 .05615214 . 1.447158 1 "Advent Software, Inc." 2006 12 .081481 .0904651 .0790622 .0904651 .12509376 .12507087 .03285786 .04850854 .05660743 . .69897 1 "Advisory Board Company" 2006 10 .00012838263 .000631844 .00012838263 .0011302705 .007410229 .007414499 .04495303 .04338438 .017886188 . .7781513 1 "Aegion Corporation" 2006 9 .010804182 .00374858 .010976252 .00374858 .018543504 .01840339 .02972461 .1170399 .0893841 . .69897 1 "Aetna Inc." 2006 13 .005842858 .005391581 .005842858 .005642032 . . . . . 0 1.230449 1 "Affymetrix, Inc." 2006 7 .0010492565 .0029057174 .0008599162 .003211937 .03839133 .03751501 .005582 .0044881687 .01812628 . 1 1 "Agenus Inc." 2006 7 .012486695 .000024859944 .012486695 .000024859944 .08659915 .09011953 .11943369 .0029215985 .0746722 . .4771213 1 "AirTran Holdings Inc" 2006 16 .011959202 .006713662 .011691827 .0004628821 .10768963 .1075638 .04393008 .18452998 .14383279 . 1.0413927 1 "Airgas, Inc." 2006 11 .00053039513 .00025653496 .0005793313 .0007884498 .02649861 .02654775 .10901853 .3417557 .3314269 0 1 1 "Airspan Networks Inc." 2006 3 .0780293 .08022613 .0780293 .0885741 .14691055 .14690965 .2577134 .08297233 .06268026 . .7781513 0 "Akamai Technologies, Inc." 2006 12 .022281336 .022392774 .025114903 .02536578 .0006244992 .00055736 .026950195 .04688368 .04298013 0 1.1760913 1 "Alaska Air Group, Inc." 2006 16 .14319295 .1365907 .14337961 .13680068 .0770879 .07705175 .13736704 .3419811 .5625353 . .9542425 1 "Alaska Communications Systems Group, Inc." 2006 18 .011240158 .014438976 .011240158 .013700788 .021481875 .02149023 .003259521 .2518523 .3938593 . .845098 1 "Albany Molecular Research, Inc." 2006 10 .010876543 .011699588 .010876543 .011699588 .017489953 .017498706 .0032979215 .0002371978 .020459224 . .4771213 1 "Albemarle Corporation" 2006 6 .02005215 .026694134 .020291 .02648918 .070482604 .07048711 .10056126 .07605447 .02961354 . 1.0791812 1 "Alcoa Corp." 2006 1 . . . . . . . . . . 1.30103 . "Alere Inc." 2006 7 .04322944 .04280767 .04322944 .04280767 .03334241 .032626957 .05462692 .06765131 .010167497 . .4771213 1 "Alexion Pharmaceuticals, Inc." 2006 7 .0022933334 .00007111111 .003034074 .00007111111 .12444791 .12642404 .12685034 .0027634955 .14503986 0 .90309 1 "Align Technology, Inc." 2006 7 .02066306 .034437403 .01666306 .034437403 .02015948 .02053391 .09385595 .06389891 .1217781 . .9542425 1 "Alkermes Plc" 2006 7 .002307636 .0000955021 .002307636 .00017175733 .04019735 .04086959 .02674555 .014335112 .04435673 0 1.1139433 1 "Allegheny Energy" 2006 17 .003341232 .0028477095 .003657188 .002709321 . .01674376 . . . . .90309 1 "Allegheny Technologies Incorporated" 2006 1 .006357261 .006657428 .005756652 .006449557 .06650042 .06656262 .005805565 .04528506 .0044380394 0 1.0791812 1 "Allergan plc" 2006 7 .16883266 .16734266 .16896462 .16773424 .09867306 .09751353 .02054788 .2344698 .07064394 0 1.230449 1 "Allergan, Inc." 2006 7 .04038625 .04099796 .04184198 .0419346 .007100201 .006860672 .007003808 .030943366 .05281864 . 1.0413927 1 "Alliance Data Systems Corporation" 2006 12 .012541012 .013489045 .014226405 .01535 .02612739 .02602331 .08186956 .0571612 .13129315 0 1.0413927 1 "Alliance Holdings GP, L.P." 2006 5 . . . . . . . . . . .60206 1 "Alliance Resource Partners, L.P." 2006 5 .01521129 .0010763442 .007236022 .0010532258 .06197545 .06227554 .09023703 .4665673 .4448465 . .4771213 1 "Alliant Energy Corp" 2006 17 .022287445 .024099857 .022673324 .024099857 . .00318698 . . . . .60206 1 "Allos Therapeutics Inc." 2006 7 .009148837 .0017069768 .00635814 .0017069768 . . . . . . .69897 1 "Allscripts Healthcare Solutions, Inc." 2006 12 .01593291 .009434477 .010972388 .01022612 .06971319 .06931785 .0013465788 .011487003 .03573601 . 1.1760913 0 "Alnylam Pharmaceuticals, Inc" 2006 7 .004698353 .0003697605 .0018540418 .0003570359 .034546584 .03297841 .022549564 .0142175 .06226688 . .845098 1 "Alon USA Energy, Inc." 2006 5 .01918677 .02174504 .024275826 .02030687 .0282023 .027876886 .21352224 .184881 .0467662 . .845098 1 "Alpha Natural Resources, Inc." 2006 5 .03055752 .06808485 .03453514 .06808485 .15081254 .15101677 .0786851 .211309 .020657115 . .9542425 1 "Alphabet Inc. Class A" 2006 12 .0008549825 .000019602176 .000013292877 .000627944 .017694604 .017605238 .0193095 .016315911 .008344107 0 1.462398 1 "Alphatec Holdings, Inc." 2006 7 . . . . . . . . . . .4771213 1 "Altera Corporation" 2006 3 .0028898004 .0006195359 .0040555852 .0008175931 .017644044 .017644042 .0443513 .07306529 .04104874 0 1.3802112 1 "Altria Group Inc" 2006 8 .0038593416 .0009108673 .003956638 .0009385707 . .02271979 . . . 0 .9542425 1 "Altus Pharmaceuticals Inc." 2006 7 . . . . . . . . . . .69897 1 "Amazon.com, Inc." 2006 15 .000354825 .00131158 .000354825 .00014273595 .02059263 .02059382 .0027127226 .031447113 .0021231333 0 1.230449 1 "Amedisys, Inc." 2006 13 .002417614 .0005037879 .000918245 .0004242424 .0173034 .017307507 .0079561025 .0906691 .12856597 . .90309 1 "Ameren Corporation" 2006 17 .001746487 .0024637 .001746487 .002331967 . .03777529 . . . 0 .90309 1 "America's Car-Mart, Inc." 2006 15 .009254238 .00043099275 .005924939 .00043099275 . . .0015061384 .1291201 .1084188 . .69897 0 "American Axle & Manufacturing Holdings, Inc." 2006 2 .26326793 .2643679 .26429898 .2623925 .10443112 .10443112 .06095796 1.0155913 .3399317 . 1.1139433 1 "American Commercial Lines Inc." 2006 16 .0027401056 .0027473615 .0016916228 .003010884 .01279793 .012780335 .0694089 .09932567 .0755669 . .90309 1 "American Eagle Outfitters, Inc." 2006 15 .0028818536 .002667755 .003242167 .002589426 .018848013 .018845877 .1515835 .13217816 .02756769 . 1.2787536 1 "American Electric Power Company, Inc." 2006 17 .00477622 .006550013 .006354004 .006838501 . . . . . 0 1.20412 1 "American Greetings Corporation Class A" 2006 8 .01338976 .0014037323 .0027692306 .0014037323 .2141283 .19384134 .08894201 .16824593 .17475043 . .4771213 1 end
0 Response to Loop (Macro) Regressions to output coefficients and p-values
Post a Comment