Dear all,

Hope all is well.

Context: I am in the process of regressing director-turnover on the board of a company (identified as dummy variable = 1 if turnover event happens in that year), on a number of independent variables including company's stock return performance over 1, 2 and 3 years.

Data: My data has director-firm-year observations (1 observation for each director, in each company, for each year). Sample is below:
Code:
input int year double permno int(fyear meetingdate) long our_director_id int age byte female float(left_early ind_adj_ret)
1996 78791 1995 13285  38111000 73 . 1  13.151268
1996 14702 1995 13222  33878000 66 . 0    12.2449
1996 11404 1995 13289      4346 43 . 0 -15.231146
1996 90721 1995 13272  31963000 51 . 0   8.038734
1996 20183 1995 13285  40459000 53 . 0  -5.435533
1996 41355 1996 13445  39443000 69 . 0 -2.2939062
1996 53065 1995 13289      4744 55 . 0 -16.172775
1996 49744 1995 13285  34949000 65 . 0   .9351444
1996 58755 1995 13273      4007 71 . 0 -11.683067
1996 34841 1995 13292  38002000 84 . 0 -11.037954
1996 67176 1996 13460      5666 72 . 0  2.3997774
1996 27051 1995 13263  36200000 57 . 0 -14.071634
1996 78975 1995 13165      2426 44 . 0   54.14909
1996 75489 1995 13292 201534000 45 . 1   43.11556
1996 13688 1995 13256       428 66 . 0  -26.11026
1996 65817 1995 13273 201523000 57 . 0 -20.604166
1996 55597 1995 13276       754 56 . 0  -12.89924
1996 27633 1995 13272      2686 54 . 0 -10.729064
1996 35051 1996 13472      5137 81 . 0  -8.403617
1996 49429 1995 13287 200327000 53 . 1  20.802996
1996 68494 1995 13473 200552000 46 . 0  -13.40749
1996 30680 1995 13173      5474 55 . 0  -6.006222
1996 27633 1995 13272  36104000 65 . 0 -10.729064
1996 56266 1995 13282      3653 64 . 0   3.263151
1996 48523 1996 13471  33717000 66 . 0   21.90117
1996 25320 1996 13415 200211000 57 . 1   58.16761
1996 74230 1995 13236  34285000 71 . 0  -7.106485
1996 43553 1995 13255  31590000 67 . 0  15.526155
1996 27780 1995 13269      3966 47 . 0   89.00487
1996 38578 1995 13270      3788 61 . 0  -13.84472
1996 70308 1995 13366 201385000 69 . 1   59.21646
1996 75654 1995 13251  36850000 66 . 0   61.75616
1996 76492 1995 13263  35608000 68 . 0   9.414017
1996 58246 1995 13255       318 62 . 0   42.52085
1996 11607 1995 13242  34448000 61 . 0   23.50525
1996 77637 1996 13471  38673000 73 . 0   2.746721
1996 75819 1995 13284      2703 48 . 0  -32.38974
1996 26710 1995 13283  37598000 83 . 0 -1.0945435
1996 87127 1995 13270       864 49 . 0 -37.093536
1996 24985 1995 13209  34514000 66 . 0   2.196209
1996 22293 1995 13264      2216 57 . 0  -5.990883
1996 11403 1995 13272      1457 48 . 0  142.31427
1996 10460 1995 13262      1207 54 . 0  -6.083118
1996 78946 1995 13258  34774000 70 . 1  17.288269
1996 78928 1995 13297  38621000 62 . 0   33.46526
1996 78928 1995 13297  38622000 67 . 0   33.46526
1996 75241 1995 13278  32815000 43 . 0    6.72043
1996 75654 1995 13251 201412000 51 . 1   61.75616
1996 80072 1995 13241  34417000 55 . 0  -6.115255
1996 51369 1995 13292  32725000 56 . 0  -47.30177
1996 24360 1995 13278      2454 61 . 0    .987216
1996 18016 1995 13264  36074000 64 . 0  12.724827
1996 78916 1995 13279      4645 53 . 0  -51.63638
1996 48506 1995 13255      3012 66 . 0 -16.384653
1996 50905 1995 13265       173 57 . 0 -14.914303
1996 21282 1995 13264  36315000 78 . 0   26.61349
1996 50024 1995 13255  32084000 64 . 0  18.354536
1996 39917 1995 13255      2897 53 . 0   8.930243
1996 52476 1995 13270      2264 62 . 0   15.83344
1996 56143 1995 13269  36391000 70 . 0  -24.86207
1996 13936 1995 13318      1842 57 . 0 -20.055765
1996 59459 1995 13276  36425000 45 . 0  -14.52517
1996 75615 1995 13292  40926000 67 . 0   29.82071
1996 35211 1995 13278      4157 60 . 0 -30.684635
1996 62519 1995 13290      4742 37 . 0   64.42719
1996 48961 1995 13276      4122 68 . 0   -31.7728
1996 65074 1995 13298  38332000 68 . 0   95.01543
1996 34833 1995 13265      3068 65 . 0  -6.114417
1996 63483 1995 13297 200804000 70 . 1 -26.318604
1996 50876 1995 13254  34008000 67 . 0 -2.1853828
1996 20183 1995 13285  37654000 57 . 0  -5.435533
1996 21338 1995 13263  36155000 62 . 0  -6.882256
1996 18374 1995 13255      2910 57 . 0  1.6626244
1996 48389 1995 13283  37711000 66 . 0 -21.129177
1996 43350 1995 13256  34335000 70 . 1   41.83089
1996 11127 1995 13269 201492000 59 . 0  -63.20605
1996 11850 1995 13263  37798000 69 . 1   4.774702
1996 80694 1995 13292 201737000 69 . 0 -.19219208
1996 35175 1995 13257      4013 62 . 1  12.587743
1996 78180 1995 13304  38599000 48 . 0  -63.20605
1996 40483 1995 13285      2915 56 . 0  -12.20704
1996 24184 1995 13276  36551000 68 . 0  -56.84167
1996 80654 1995 13244      2592 60 . 0  -13.19672
1996 76091 1996 13465  32427000 66 . 0  38.057514
1996 34746 1995 13227      2370 55 . 0    54.4802
1996 53401 1995 13461 200271000 63 . 0 -19.353674
1996 44599 1995 13289  37724000 65 . 0 -26.374424
1996 78859 1995 13283  36966000 49 . 0          0
1996 25129 1995 13256      1080 45 . 0    14.3304
1996 24467 1995 13284 200924000 45 . 0  2.5272436
1996 26112 1996 13446  40843000 69 . 1   4.103896
1996 75655 1995 13318  38871000 63 . 0  -63.20605
1996 43721 1995 13261       945 53 . 0  -25.42431
1996 12062 1995 13473      5328 45 . 0  -63.20605
1996 11976 1995 13380      5256 59 . 0   84.78006
1996 60695 1995 13262  36112000 77 . 0    43.0281
1996 78859 1995 13283 201689000 42 . 0          0
1996 62463 1995 13269  32002000 54 . 0  -6.447252
1996 64486 1995 13275  31625000 64 . 0  32.173347
1996 10225 1995 13270      2904 63 . 0 -26.909966
end
format %td meetingdate
1. I want to separate the performance of the company vs. that of the industry (idiosyncratic return vs. peer return). So, I have company performance and industry performance. According to research papers, the ideal way to do this is to conduct a two-stage method to estimate both peer (industry) and idiosyncratic (firm-specific) performance. Could you please help me understand the commands needed to conduct the below to generate variables using reg and resid commands?
  • Firstly, the industry-induced component of stock returns is estimated as the fitted value from cross-sectional regressions using one-year lagged returns of the sample firms on the corresponding median industry return
  • Secondly, Idiosyncratic stock returns are then estimated as the residual from this fitted value.
2. I want to create a 3-year rolling-average line chart of director-turnover by year (number of turnover events in that year / total number of observations in that year * 100). Simply doing graph left_early, over(year) would yield yearly average, so to create a 3-year rolling average do I need to create a new variable, or can I adjust the command to calculate it?

Thank you!