Hi all,
I want to create a table that summarizes the mean and t-stat (adjusted by newey-west) for each group q5tff12_cei. I can use the newey2 command. However, I am struggling to loop it for each group and variable in the varlist.
In a second step, I would like to include the high-minus-low difference (q5tff12_cei==5 - q5tff12_cei==1) for the varlist also with their mean and t-stat.
I have seen similar questions in statist and other forums, but the t-stats setting is often omitted in the solutions. (Here is one example of the output: https://www.researchgate.net/figure/...tbl2_344137481)
Previous thread: https://www.statalist.org/forums/for...standard-erros
I want to create a table that summarizes the mean and t-stat (adjusted by newey-west) for each group q5tff12_cei. I can use the newey2 command. However, I am struggling to loop it for each group and variable in the varlist.
Code:
foreach v in r_rf100 m1_36_b_cons100 m2_36_b_cons100 m3_36_b_cons100 m4_36_b_cons100 {
newey2 `v' , lag(2) force
matrix s`v'=r(table)
local m`v'=s`v'[1,1]
local t`v'=s`v'[3,1]
}
I have seen similar questions in statist and other forums, but the t-stats setting is often omitted in the solutions. (Here is one example of the output: https://www.researchgate.net/figure/...tbl2_344137481)
Code:
egen bin1 = mean(cond(q5tff12_cei == 1, `v', .)) , by(tid) egen bin5 = mean(cond(q5tff12_cei == 5, `v', .)) , by(tid) gen diff = bin5 - bin1 egen tag = tag(tid)
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int tid byte q5tff12_cei float(r_rf100 m1_36_b_cons100 m2_36_b_cons100 m3_36_b_cons100 m4_36_b_cons100) 86 1 -.9058677 .02145035 -.5133076 . . 86 3 -.54829586 .007798558 -.3217252 . . 86 4 -.7924957 -.13309352 -.5353951 . . 86 5 -.8188509 .14800759 -.6585122 . . 86 2 -1.392441 -.09106115 -.5063971 . . 86 . -.8176172 .14167596 -.5689561 . . 87 4 -.4994625 -.13481165 -.4941774 . . 87 2 -.4235277 -.07563148 -.4672495 . . 87 5 -.4575529 .15376803 -.5376602 . . 87 1 -.560716 .015838677 -.4342453 . . 87 . -.13789426 .18234202 -.4187314 . . 87 3 -.195949 .027872445 -.27323663 . . 88 3 -2.244029 .07282455 -.3411356 . . 88 . -1.3531368 .17421243 -.463998 . . 88 4 -1.6350974 -.13405831 -.5316094 . . 88 2 -1.1447809 -.08630008 -.4960694 . . 88 1 -1.50142 .022053374 -.5060614 . . 88 5 -1.7348807 .14869703 -.5942729 . . 89 . -1.3788006 .10646114 -.3572438 -1.4336963 . 89 5 -.6789171 .1078643 -.3717572 .6818098 . 89 2 -.3911406 -.06569249 -.46530285 -.063956186 . 89 3 -.4863502 .10742719 -.3217531 .4667303 . 89 1 -.7137817 .023021087 -.4299444 .07142119 . 89 4 -.6088675 .025009833 -.4589723 -.3213624 . 90 4 -.15855773 .035381924 -.4447816 .23818554 . 90 3 -.6821374 .0917111 -.3481893 .5317443 . 90 . -.3150053 .09298427 -.3234789 -1.2957773 . 90 2 -.4583499 -.08870088 -.4589669 -.28811198 . 90 1 -.25472417 .02566425 -.4013398 -.04163263 . 90 5 -.3388736 .09880327 -.3387266 .13736273 . 91 5 -1.9779067 .0932262 -.3789137 .5990013 1.0844077 91 4 -1.3207444 .04436278 -.27458978 .14391078 -.3816495 91 . -1.834382 .08780798 -.3606023 .21650414 1.1738223 91 3 -1.3335826 .07369188 -.1792246 .13873807 .1561591 91 2 -1.1659441 -.09610167 -.5130596 -.7263395 -.6998454 91 1 -1.0754869 .021283757 -.4037825 -.102217 -.07726553 92 4 .907261 .016734086 -.06592408 -.12533936 -.19086044 92 1 .7676252 -.001092603 -.2680265 -.07129515 -.10131808 92 2 .9949204 -.04489993 -.3577947 -.005866827 -.1171619 92 5 .8314697 .025181444 -.2588099 .2061792 .3532049 92 3 .7922711 .02053701 -.1316534 -.0883946 -.11326556 92 . .7848737 .030563535 -.24317592 .07588402 .54640347 93 4 1.1943066 .033072937 -.093111 -.13601123 -.10399254 93 5 .8096113 -.0002958782 -.1788198 .26832145 .422369 93 1 .784494 -.007037275 -.1973076 -.06131066 -.10275106 93 2 .730377 -.02804178 -.27125978 -.023110393 -.17123555 93 . .6357299 -.017439766 -.21556947 .17196745 .5861715 93 3 .7985401 .016996613 -.13159542 -.08310654 -.1005657 94 2 .04613707 -.0001698827 -.18757653 -.04608641 -.1054706 94 1 -.15152827 -.003594554 -.17556114 -.09571478 -.13439836 94 . .1024031 -.007632277 -.20415895 .179725 .3520409 94 4 .29462224 .05989672 -.04768859 .016752006 .10590526 94 5 -.25857756 .02861041 -.09005198 .191555 .2025821 94 3 -.05090784 .04046358 -.0817152 -.013069365 -.005560877 95 5 -.03592813 .03007918 -.08658373 .18172136 .18571845 95 4 -.13757233 .14066373 -.05724081 -.007348554 .053703 95 3 .03747668 .024384154 -.08293262 .006611405 .033984605 95 . -.6564144 -.13107581 -.23329076 .1244009 .20811473 95 2 .1315623 -.011155094 -.1941448 -.24408028 -.3841661 95 1 -.08059702 .005039782 -.14912602 -.07939667 -.09958822 96 . .4439951 -.10423081 -.088352 .09036473 .18193167 96 2 .384435 -.0018972757 -.17349093 -.2480711 -.2961874 96 1 .30849355 .013239567 -.08491775 -.07234371 -.08103934 96 5 .41281855 .04077229 -.06645943 .14150228 .16072726 96 4 .14657876 .09617349 -.029761223 -.07795671 -.05452909 96 3 .27145657 -.0019000027 .017312648 .07120681 .15284576 97 4 -1.6705427 .04977978 -.23416144 -.03977782 -.06773295 97 2 -1.584259 -.02897925 -.3050644 -.1941846 -.26843867 97 1 -1.3243084 .008378604 -.23404297 -.05093854 -.0881025 97 5 -1.313684 .04048981 -.19756977 .236945 .1683515 97 . -1.1722813 -.02551714 -.25745 .1193611 .20604254 97 3 -1.1351775 .008934536 -.19598512 .05593761 .11466429 98 . -.35816514 -.020468537 -.2591394 .1350842 .2124718 98 1 -.57744205 .017041732 -.23995434 -.06447691 -.13441144 98 4 -.1786192 .05448829 -.2252759 -.018222926 -.015926732 98 3 -.4380982 .10813462 -.1983827 .18048193 -.04491992 98 2 -.8885735 -.01943633 -.354509 -.072995946 -.07638998 98 5 -.5915332 .10090943 -.15816402 .16434544 .3496739 99 1 .5583053 .0187254 -.21211076 -.03839991 .1825512 99 5 .9389119 .1144607 -.09743308 .19548702 .2232331 99 . .6306077 -.024765786 -.2216796 .18600138 .22256373 99 4 .6858774 .015909484 -.19435076 -.03802592 -.04549261 99 3 .4434504 .063795 -.1926676 .20501593 .9650498 99 2 .8218694 -.07152853 -.2901345 -.10777871 -.10874038 100 3 -.6110428 .07750777 -.28019047 .1584599 .4043739 100 1 -.8564146 .035812836 -.2922655 -.032617584 .0004658565 100 2 -.6212319 -.066361755 -.3615647 -.07223734 .07370194 100 4 -1.3559097 .005161516 -.3726394 -.016816758 -.012078474 100 5 -1.0007552 .09278229 -.211913 .28992423 .7417828 100 . -.4480376 .006043409 -.26522812 .11860619 .2026938 101 3 -.627744 .008037733 -.3211292 .06238318 .295826 101 4 -.51799715 .05350077 -.2682942 .03234001 .04698205 101 . -.941622 -.02296777 -.2681932 .12717696 .06404302 101 1 -.4040735 .036719255 -.3264958 -.029586524 .003810064 101 5 -.3665016 .05042713 -.340235 .1659412 .3684133 101 2 -.3159778 .015262783 -.3064959 .036350425 .2334717 102 . -1.949873 -.04453398 -.3703464 .27378672 .3302562 102 5 -1.6331242 .06885544 -.4526368 -.07745778 -.12736231 102 3 -1.203413 .005697238 -.41238025 -.06623104 -.04865731 102 2 -1.925132 -.02015427 -.7191985 .3081228 .46640855 end
Previous thread: https://www.statalist.org/forums/for...standard-erros

Comment