Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to divide my data set into sub-sample(s) and generate a variable leader/ follower for examining mimicking behavior



    Hello Dear professor.
    I have a quarry about a problem. I have the following data consist of two groups variables. The first one is the firms' specific variables( bl, prof, tang,size liqu, bk, nts,gao andieqshok) and the second group is the peer firms average characteristics (pbl, pprof, ptang, psize, pliqu, pbk, pnts, pgoa and peqshock). My basic objectives are to divide my data into sub-sample and create leader and follower firms based on size, prof and goa. Further, i want to examine mimicking behavior between leader and follower ( who follow whom). My limited knowledge donot enable me. so kindly if possible assist me. Your valuable insight will be highly appreciated. Sorry for inconveniences.

    [HTML]
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int(companyid year) float(bl pbl prof tang size liqu bk nts gao ieqshok pprof ptang psize pliqu pbk pnts pgao iaeqshock)
     1 2011  .24794 .393869   .08435 .427675  7.7274 1.70839 .020751 .036037 -3.78408 .000085   .04356  .36046 5.29694  2.7034  .327713 -.036451  1.00265 .000152
     1 2012 .228582 .398956  .099142 .412992  7.7274 1.67297 .020751 .037425 -1.77693 .000453  .038517 .367371 5.30874 2.69247 -.005217  .032469  4.60129 .000334
     1 2013  .20635 .378759  .114672 .397599  7.7274 2.00966 .020751 .034749 -1.32234 .000111 -.021454 .362777 5.34636 3.05064  .321999  .032744 -.021547 .000283
     1 2014 .204459 .414312  .123248  .37271  7.7274 2.19686 .020751  .03513  1.24052 .000155  .013539 .361989 5.38515 2.89328  .330657  .032363  1.00265 .000198
     1 2015  .21693 .440635  .082983 .367576  7.7274  1.9417 .020751 .037851 -1.39517 .000085  .040915 .354502 5.46115 3.15969  .321627 -.003254  .003655 .000169
     1 2016 .290245 .391355  .078592 .380793  7.7274 1.10949 .020751 .035431  9.22901 .000068    .0475  .34688 5.50848 3.59625  .312616 -.003254 -1.02486 .000184
     2 2011 .479802 .392521 -.100327 .347442  5.2937 1.62546 .370811  .03803  15.3895 .000037   .04527 .360924  5.2996 2.70389  .325668 -.036451  1.00265 .000153
     2 2012 .538248 .397166 -.100327 .397515 5.18176 1.34115 .414751 .042591 -10.5898 .000225  .039745 .367461 5.32681 2.69439  .325971  .032439  4.65253 .000335
     2 2013 .681036 .377169 -.100327 .383503 4.91558 .849131 .541331 .069776 -20.1742  .00062  .037204 .362858 5.36589 3.05735 -.007452  .032378  5.54665  .00028
     2 2014 .666305 .411642 -.100327 .481143 4.68968 .799558 .678611 .069776 -20.1742 .000104  -.00547 .361362 5.40605 2.90135  .327326  .032155  1.00265 .000198
     2 2015 .222728 .440635  .009438 .522075 4.80972 2.28331 .601944 .042927  12.7543 .000127 -.006981 .353609 5.48128 3.15772 -.007452 -.003254  .003655 .000169
     2 2016 .094859 .392491  .109302 .451085 5.29674 6.24624 .369952 .030994  38.2993 .000101    .0475 .346491  5.5263 3.56848 -.007452 -.003254  1.02548 .000184
     3 2011 .094324 .394763  .096062 .339468 6.94076 8.52213 .071495 .041836  5.18581  .00015  .043492  .36097 5.29694 2.68017  .327409 -.036451  1.00265 .000152
     3 2012 .116487 .399604  .088276 .313943 7.01329 7.15626 .066472 .039101  7.52206  .00062   .03858 .367944 5.31622 2.68017  .327984  .032459  4.54722 .000333
     3 2013 .104639 .379346  .084263 .314325 6.96991 8.30202 .069397 .040393 -4.24555 .000134  .035162 .363258 5.35401 3.01427  .321709  .032711 -.021547 .000283
     3 2014 .114972 .414829  .088111 .314303 6.92337 7.00414 .072685 .043838 -4.54665 .000136  .013742 .362327 5.39314 2.86549  .330657  .032312  1.00265 .000198
     3 2015 .151004 .440635  .112954 .331554  6.8298 4.61005 .079796 .049306 -8.93337 .000091  .040742  .35471  5.4696 3.14427  .321275 -.003254  .003655 .000169
     3 2016  .16431 .392087  .122701 .345153 6.73981 4.00293 .087272  .05761 -8.60539 .000091    .0475 .347086 5.51796 3.58145   .31221 -.003541 -1.02486 .000184
     4 2011  .22289 .394015  .160909 .221794 6.24579 2.66667 .143116 .031622  12.8301 .000131  .042871  .36165 5.29694 2.69783  .326992 -.036451  1.00265 .000152
     4 2012 .167266  .39931  .160909 .193911 6.30473 3.83517 .134907 .031843   6.0707 .000189  .038065 .368265 5.32031 2.68017  .327588  .032501  4.55566 .000336
     4 2013 .130649 .379196  .160909  .29378 6.33324 5.09858 .131106  .03104   2.8917 .000164 -.021454 .363377 5.35769 3.03279  .321353  .032765 -.021547 .000283
     4 2014 .139145 .414689  .160909 .320402 6.39488 4.76704  .12326 .032977  6.35872 .000147  .013201 .362291 5.39619 2.87842  .330536  .032375  1.00265 .000198
     4 2015 .213642 .440635  .137397 .301975 6.56921 3.31971 .103521  .03397  19.0441 .000083  .040601 .354881 5.47111 3.15173  .321137 -.003254  .003655 .000169
     4 2016 .149251 .392174  .126759 .349349 6.52877  5.4021 .107777 .036114 -3.96252 .000118    .0475 .347062 5.51918 3.57336  .312092 -.003254 -1.02486 .000184
     5 2011 .272831 .393725  .057387 .163379  5.6177 2.46031 .268294  .01818  6.35244 .000069  .043716 .361988 5.29772 2.69903  .326264 -.036451  1.00265 .000152
     5 2012 .274399 .398691 -.012078 .218252 5.57698 2.59995 .279518 .018787 -3.99012  .00062   .03916 .368265 5.32452 2.68711  .326753  .032577  4.61416 .000331
     5 2013 .223756 .378658 -.024764 .224461 5.44896 3.22101 .317764 .021173  -12.016 .000215  .035792 .363777 5.36281 3.04364  .320274  .032822 -.021548 .000282
     5 2014 .136146 .414707  .049861 .075372 5.27896 6.66688 .376733  .01619 -15.6341 .000075  .013963 .363912 5.40264 2.86744  .329071  .032472  1.00265 .000198
     5 2015 .093913 .440635        0 .075372 5.48656 8.52213 .306183 .005721  23.0729 .000094 -.006981 .356488 5.47736 3.08599  .319966 -.003254  .003655 .000169
     5 2016 .093913  .39277  .015456 .075372 5.46149 8.52213 .313957 .005721 -2.47612 .000135 -.021492 .348937 5.52534  3.5071 -.007452 -.003254 -1.02486 .000184
     6 2011 .093913 .395073  -.03246 .663208 5.28902 7.95497 .373523 .015438  7.63819 .000103  .044235 .359099 5.29963 2.68017  .325653 -.036451  1.00265 .000152
     6 2012 .093913 .399999 -.017991 .649653 5.29994 7.02499 .369546 .012804  1.09766 .000242  .039195 .366003 5.32612 2.68017  .326232  .032611  4.58458 .000335
     6 2013 .093913  .37974 -.009577 .658118 5.27224 8.52213 .380009    .014 -2.73207 .000183  .035704 .361271 5.36383 3.01005  .319914  .032822 -.021547 .000282
     6 2014 .093913 .415297  .018357 .636545 5.29577 8.52213 .371254 .013033  2.38131 .000186  .014145 .360464 5.40255 2.84606  .329102   .03249  1.00265 .000198
     6 2015 .093913 .440635  .001432 .075372 5.60738 8.52213 .271922  .01302   36.562 .000078 -.006981  .35639 5.47667 2.91318  .320164 -.003254  .003655 .000169
     6 2016 .093913 .392895 -.020669 .075372 5.51112 8.52213 .299467 .008115  -9.1767 .000125 -.021492 .349023 5.52506 3.41223 -.007452 -.003254 -1.02486 .000184
     7 2011 .633364 .391629  .033307 .591181 7.47041 1.21978 .042216 .009749  37.1848 .000038  .043855 .359515 5.29694 2.70625  .327579 -.036451  1.00265 .000153
     7 2012 .592342 .396853  .007558 .692048 7.39526 1.05597 .045519 .021555 -7.23896 .000052  .039047 .365708 5.31401 2.69604 -.005217  .032561  4.63305 .000336
     7 2013  .66446 .377169 -.020276 .692048 7.36405 .762605 .046974 .033093 -3.07274 .000119  .035766 .360923 5.35174 3.05985  .321839  .032753 -.021547 .000283
     7 2014 .704567 .411021 -.014064 .692048 7.26145 .762605 .052064 .035208 -9.75205 .000179  .014332 .359882 5.39118 2.90391  .330657  .032362  1.00265 .000198
     7 2015 .423234  .43954  .012416 .578693 6.53692 1.03581 .107476 .025694 -20.1742 .000043 -.006981 .353282 5.47129 3.16493  .321115 -.003254  .003655 .000169
     7 2016 .460266 .390366  .010049 .579276 6.55047 1.07472 .106059 .025943  1.36389 .000404 -.021492 .346491 5.51905 3.59625  .312101 -.003254 -1.02486 .000183
     8 2011 .218772 .394039  .106578 .475406 7.08693 2.72139 .062018 .039588  1.89943 .000218  .043431 .360184 5.29694 2.69752  .327464 -.036451  1.00265 .000152
     8 2012 .263261 .398755  .100168 .477767 7.18764 2.61424 .056034 .037897  10.5961 .000235  .038512 .366997 5.31521 2.68703 -.005217  .032466  4.52935 .000335
     8 2013 .239827 .378565   .10029 .447449 7.21463 3.14282 .054494 .038874  2.73556 .000272  .035069 .362488  5.3526 3.04409  .321796   .03272 -.021547 .000282
     8 2014 .279212  .41388  .106525 .453286 7.33183 2.59935  .04842 .029499  12.4339 .000097  .013635 .361523 5.39078 2.89095  .330657  .032395  1.00265 .000198
     8 2015 .294547 .440284   .07867 .485346 7.44445 2.26992 .043207 .029414  11.9206 .000122   .04094 .353821 5.46605 3.15779  .321486 -.003254  .003655 .000169
     8 2016 .322984 .391164  .081193  .44977 7.61662 2.03576  .03634 .032764  18.7883 .000108    .0475 .346491 5.51289 3.59282  .312505 -.003254 -1.02486 .000184
     9 2011 .498503 .392413  .048009 .615192 7.02101 1.04237 .065854 .035743   21.037 .000188   .04377 .359376 5.29694 2.70728  .327441 -.036451  1.00265 .000152
     9 2012 .508391 .397339  .040101 .586236 7.13574 1.02276  .05872 .038116  12.1574 .000115  .038859  .36637 5.31551 2.69623 -.005217  .032465  4.52028 .000336
     9 2013 .503391 .377169  .045708 .594036 7.12808 1.01399 .059174 .045004 -.762859  .00033  .035385 .361641  5.3531  3.0564  .321769  .032684 -.021547 .000282
     9 2014 .450319 .412891  .033258 .654948 7.30834 .957111  .04941 .036942  19.7525 .000227  .014059 .360358 5.39091 2.90044  .330657  .032352  1.00265 .000197
     9 2015 .469327 .439274   .03139 .640862 7.36028 .961281 .046909 .036138  5.33097 .000219 -.006981 .352922 5.46653 3.16536  .321465 -.003254  .003655 .000168
     9 2016 .453454 .390406  .043153 .631776 7.36685 .987197 .046601 .033858  .660065 .000049 -.021492 .346491 5.51433 3.59625  .312445 -.003254 -1.02486 .000185
    10 2011 .163274 .394362   .03302  .39411 5.43734  6.0162 .321288 .049737  1.63758 .000089  .043857 .360654 5.29877 2.68017  .325956 -.036451  1.00265 .000152
    10 2012 .151249 .399403  .008326 .453211  5.3927 6.62744 .336045 .050224 -4.36542 .000151  .039042 .367139 5.32559 2.68017  .326426  .032395  4.61634 .000336
    10 2013 .163343 .379007 -.019869  .43921 5.36385 5.66776 .345972 .059458   -2.844 .000123  .035764 .362536  5.3633  3.0295  .320111  .032601 -.021547 .000283
    10 2014 .177079  .41447  -.01549  .41689 5.37024 4.94258 .343854 .057497  .641551 .000152   .01434 .361734 5.40212 2.87741  .329261  .032233  1.00265 .000198
    10 2015 .261361 .440476 -.007737  .36382 5.43052 3.05866 .323823 .050274  6.21269 .000078 -.006981 .354524 5.47769 3.15324  .319864 -.003254  .003655 .000169
    10 2016 .215364  .39179  .020841 .327087 5.34584 4.01102  .35253 .056782 -8.11944 .000246 -.021492  .34719 5.52601  3.5814 -.007452 -.003541 -1.02486 .000183
    11 2011 .505946 .392369 -.006096 .311361 5.11406 1.54582 .445148 .011188 -1.61701 .000065  .044083 .361133 5.30064 2.70435  .325236 -.036451  1.00265 .000153
    11 2012 .472709 .397545  -.03008 .477407 5.32601 1.33263 .360212 .007772  23.6083 .000203  .039264 .366999 5.32597 2.69444  .326286   .03264   4.4537 .000336
    11 2013 .437614 .377422 -.034041  .53814 5.18437  1.2383 .415111 .013269 -13.2062 .000145  .035846 .361964 5.36434  3.0551  .319711  .032822  5.54665 .000283
    11 2014 .327423 .413601   -.0235 .259741 5.07941 1.22488 .461152 .008894 -9.96408 .000146  .014387 .362642  5.4038  2.8989 -.005217  .032514  1.00265 .000198
    11 2015 .273295 .440407 -.018054 .308287 5.06066 1.17806 .469986  .00839 -1.85774 .000061 -.006981 .354845 5.47983 3.16411  .319019 -.003254  .003655 .000169
    11 2016 .248796 .391596 -.018874 .325688 5.01661 1.23361 .491262 .008376 -4.30898 .000317 -.021492 .347198 5.52792 3.59625  .309875 -.003254 -1.02486 .000181
    12 2011 .149408 .394442  .043536 .140164 4.38264 3.33792 .927357 .009869 -.720575 .000115  .043796 .362122  5.3049 2.69393  .322433 -.036451  1.00265 .000152
    12 2012 .093913  .39998  .039898 .144178 4.29813 8.52213 1.00938 .010685 -8.10379 .000288   .03886 .368265 5.33191 2.68017  .322534  .032624  4.63807 .000335
    12 2013 .093913 .379699  .021221 .139001 4.30386 8.52213 1.00386  .01107  .575025  .00062  .035526 .364271 5.36943 2.91839 -.007452  .032822 -.021547 .000279
    12 2014 .164262 .414544  .020874 .097476    4.66 5.82736 .703247 .007261  38.2993 .000115   .01413  .36358 5.40622 2.87229  .327183  .032524  1.00265 .000198
    12 2015 .327216 .440095  .043596 .083649 4.91903 2.88647 .542896 .005721  29.5676 .000119 -.006981 .356143 5.48064 3.15423 -.007452 -.003254  .003655 .000169
    12 2016 .440066 .390484 -.005273 .080523 6.94629 1.35345 .071516 .005721  38.2993 .000164 -.021492 .348616 5.51676 3.59625  .312301 -.003254  1.23549 .000184
    13 2011 .304166 .393542  .075509 .506179 4.30574 3.72653 1.00418 .030368  2.20335 .000223  .043611 .360006 5.30534 2.69167  .321986 -.036451  1.00265 .000152
    13 2012 .293011 .398584  .057697 .491853 4.33687 3.11469 .973649 .026456  3.16227 .000261  .038757 .366915 5.33169 2.68414   .32274  .032532  4.57257 .000335
    13 2013 .255648 .378474  .071303 .490916 4.31191 3.30977 .998509 .027526 -2.46508 .000196  .035237 .362237 5.36938 3.04313 -.007452  .032786 -.021547 .000282
    13 2014 .236923 .414124  .048123 .523774 4.29217  2.5755 1.00938  .02828 -1.95487 .000262  .013973 .361116 5.40835 2.89109   .32536  .032402  1.00265 .000197
    13 2015 .176068 .440635  .021204 .537919 4.21544 3.57378 1.00938 .033947 -7.38598 .000077 -.006981 .353517 5.48471 3.15026 -.007452 -.003254  .003655 .000169
    13 2016 .233628 .391684  .023732 .489319 4.26685 3.28784 1.00938 .032259  5.27583 .000095 -.021492 .346491 5.52918 3.58558  .306672 -.003254 -1.02486 .000184
    14 2011 .450246 .392693  .035965  .17175 5.05421  1.3392 .476422 .018183 -2.22531 .000068   .04384 .361939 5.30099 2.70555  .325054 -.036451  1.00265 .000152
    14 2012 .483176 .397484  .015789 .248807 5.11959 1.23665 .446388  .02566  6.75576 .000187  .038999 .368265 5.32717 2.69499  .325788  .032537  4.55168 .000336
    14 2013 .512703 .377169  .012083 .236015 5.14595    1.24 .434883 .022412  2.67179 .000168  .035579 .363711 5.36456 3.05509  .319597  .032815 -.021547 .000283
    14 2014 .448996 .412898  .039029 .200553  5.2874 1.27038 .377618 .022737  15.1938 .000102  .014025 .362984  5.4026 2.89863  .329065  .032434  1.00265 .000198
    14 2015 .430069 .439501 -.006269 .205967  5.2111 1.19968 .407665  .02263 -7.34578 .000248 -.006981 .355436 5.47896 3.16398  .319379 -.003254  .003655 .000168
    14 2016 .497739 .390148  .071743  .16287  5.3599  1.3213 .351389 .019116   16.044 .000048    .0475  .34814 5.52593 3.59625 -.007452 -.003254 -1.02486 .000185
    15 2011 .305719 .393533  .068107 .153935 7.65673 2.97426 .032296 .014155 -7.62154 .000067  .043654 .362042 5.29694 2.69605  .327637 -.036451  1.00265 .000152
    15 2012 .237483 .398904  .077534 .218498 7.64936 3.03087 .032503  .01623 -.734199  .00049  .038642 .368265 5.31254 2.68462 -.005217  .032591  4.59523 .000334
    15 2013 .211807 .378727  .101789 .228282 7.66867 3.07147 .031836 .024662  1.95042  .00062  .035061 .363755 5.34998  3.0445  .321927  .032802 -.021547 .000279
    15 2014 .221209 .414215  .112475 .206145  7.7274 2.98918 .028017 .034476  13.2533 .000321  .013601 .362952 5.38811  2.8887  .330657  .032366  1.00265 .000197
    15 2015  .25913 .440489  .111715 .213281  7.7274 2.50586 .024099 .014959  15.5221 .000145  .040749 .355394  5.4632 3.15643  .321597 -.003254  .003655 .000169
    15 2016 .284225  .39139  .102149 .225939  7.7274 2.13996 .020751 .016505  15.3903 .000082    .0475 .347775 5.51021 3.59222  .312595 -.003254 -1.02486 .000184
    16 2011 .145193 .394467  .037755 .289208 4.27801 5.36323 .923883 .026367  1.51933 .000078  .043829 .361261 5.30551 2.68216  .322453 -.036451  1.00265 .000152
    16 2012 .110535 .399638   .01814 .274676 4.24947 7.64293 .950872 .026246 -2.81426 .000207  .038986 .368171 5.33219 2.68017  .322872  .032534  4.60732 .000335
    16 2013 .093913 .379565 -.049294 .309077 4.13975 8.52213 1.00938 .029943 -10.3913 .000382  .035934 .363288 5.37037 2.97152 -.007452  .032772 -.021548 .000281
    16 2014 .111645 .414848   .00629 .267881 4.18931 7.31746 1.00938 .028449  5.08067 .000212  .014215 .362595 5.40894 2.86368  .325408  .032401  1.00265 .000197
    16 2015 .093913 .440635 -.016319 .266833  4.1164 8.52213 1.00938 .030666 -7.03124 .000058 -.006981 .355084 5.48528 3.09713 -.007452 -.003254  .003655 .000169
    16 2016 .124229  .39232 -.100327 .294615 3.92029  7.4009 1.00938 .036081 -17.8079 .000238    .0475 .347378 5.52918 3.56181  .305068 -.003254 -1.02486 .000183
    17 2011  .48863  .39247  .051833   .3949  7.7274 .899015 .020751 .010372  3.75742 .000171  .043748  .36065 5.29694 2.70811  .327718 -.036451  1.00265 .000152
    17 2012 .434256 .397767  .010753 .426112  7.7274 1.18709 .020751 .010737 -7.75055 .000573  .039028 .367295 5.30994 2.69528 -.005217  .032623  4.63602 .000333
    17 2013 .501407 .377169  .011829 .443645  7.7274 .883292 .021727 .011619 -8.60779 .000254  .035581  .36251   5.348 3.05715  .321985  .032822 -.021548 .000282
    17 2014 .560524 .412254 -.000633 .456185  7.7274 .912113 .022884 .012535 -5.04054 .000158  .014255 .361506 5.38715  2.9007  .330657  .032493  1.00265 .000198
    end
    


    Last edited by muhammad ayaz; 13 Aug 2018, 10:18.

  • #2
    Hey Muhammed,

    Maybe it is an idea to start defining exactly what you are trying to do here for yourself and for others. It is quite hard to give you any help without this.

    I am guessing your dataset is already divided in subsamples so to speak since companies are divided in to groups following companyid.

    again I am unsure of what definitions you use?

    A leader company i.e. a company that quite possible invest alot in R&D (research and development). vs a group of company that does not.

    maybe try
    summarize yourvarhere, detail
    for different groupids to get a better sense of what your data is telling you.

    good luck

    Comment


    • #3
      Thank you so much Dear Wessel de Kroo for your response. Additionally, i divided my sample using the following command. However, this give me 1,2 and 3 in yearwise. For instance, for year 2011 and 2012, this generated 1, for year 2013 and 14, it assigned 2 and for year 2015-2016 this assigned 3. However, i want 1,2 and 3 by id not by year.


      HTML Code:
      xtile newpsize = Wpsize, nq(3)
      xtile newprof = prof, nq(3)

      Comment


      • #4
        your post:
        " Additionally, i divided my sample using the following command." what command exactly?

        " However, this give me 1,2 and 3 in yearwise." please give readers an example using dataex. install it using: ssc install dataex.

        you can use dataex your_relevant_variables here, in order specifiy relevant variables

        your objective:
        "
        however, i want 1,2 and 3 by id not by year." okay but why?

        in your first post you state: " My basic objectives are to divide my data into sub-sample and create leader and follower firms based on size, prof and goa."

        so you should think about how to define leader and follower. Maybe you can use summary statistic to determine this? Stata has a tab named: Statistics --> summaries.

        xtile newpsize = Wpsize, nq(3)
        on itself not very usefull here.

        This thread here will give you a better understanding: https://www.stata.com/statalist/arch.../msg00494.html


        Obtaining you with deciles for size for your firms. only you can decide what suits your objective though.















        Comment

        Working...
        X