Announcement

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

  • Peer Turnover Stata

    Dear readers,

    I am new on the forum, but I'm looking for your help. For my thesis I'am studying relative performance eveluation and peer replacement within a group, including some control variables. I use paneldata on the firms from the S&P 1500. All the firms in my subsample have peers (firms) which are used in relative performance evaluation benchmarking to determine executive compensation. I presented below a smaller sample of my full dataset. Three variables are shown: fiscalyear, cik (code of the company) and peercik (cik code of the peer firm)

    Example generated by -dataex-. To install: ssc install dataex
    clear
    input double fiscalyear str12 cik double peercik
    2006 "0000002488" 932787
    2006 "0000002488" 703360
    2006 "0000002488" 70530
    2006 "0000002488" 1129446
    2006 "0000002488" 97476
    2006 "0000002488" 1272547
    2006 "0000002488" 791915
    2006 "0000002488" 50863
    2007 "0000002488" 703360
    2007 "0000002488" 791915
    2007 "0000002488" 70530
    2007 "0000002488" 50863
    2007 "0000002488" 97476
    2007 "0000002488" 932787
    2007 "0000002488" 1272547
    2015 "0000002969" 884905
    2015 "0000002969" 915389
    2015 "0000002969" .
    2015 "0000002969" 313616
    2015 "0000002969" 79879
    2015 "0000002969" 30554
    2015 "0000002969" 76334
    2015 "0000002969" 31462
    2015 "0000002969" 29905
    2015 "0000002969" 1306830
    2015 "0000002969" 1024478
    2015 "0000002969" 1307954
    2015 "0000002969" 49826
    2014 "0000004127" 1045810
    2014 "0000004127" 1097864
    2014 "0000004127" 6281
    2014 "0000004127" 827054
    2014 "0000004127" 895419
    2014 "0000004127" 763532
    2014 "0000004127" 316793
    2014 "0000004127" .
    2014 "0000004127" 913885
    2014 "0000004127" 743988
    2014 "0000004127" 791915
    2014 "0000004127" 743316
    2014 "0000004127" 1054374
    2014 "0000004127" 310568
    2014 "0000004127" 1036960
    2014 "0000004127" 791907
    2014 "0000004127" 768251
    2015 "0000004127" 310568
    2015 "0000004127" 1272547
    2015 "0000004127" .
    2015 "0000004127" 1045810
    2015 "0000004127" 743988
    2015 "0000004127" 1054374
    2015 "0000004127" 1097864
    2015 "0000004127" 827054
    2015 "0000004127" 743316
    2015 "0000004127" 768251
    2015 "0000004127" 763532
    2015 "0000004127" 791907
    2015 "0000004127" 6281
    2015 "0000004127" 1036960
    2015 "0000004127" 895419
    2005 "0000004281" .
    2005 "0000004281" 4285
    2005 "0000004281" 1171264
    2005 "0000004281" 1003467
    2005 "0000004281" 889211
    2005 "0000004281" 900268
    2005 "0000004281" 863064
    2006 "0000004281" 1171264
    2006 "0000004281" 863064
    2006 "0000004281" 889211
    2006 "0000004281" .
    2006 "0000004281" 900268
    2006 "0000004281" 4285
    2012 "0000004447" 717423
    2012 "0000004447" 101778
    2012 "0000004447" 1306965
    2012 "0000004447" 93410
    2012 "0000004447" 313807
    2012 "0000004447" 821189
    2012 "0000004447" 1140625
    2012 "0000004447" 201283
    2012 "0000004447" 1163165
    2012 "0000004447" 797468
    2012 "0000004447" 6769
    2012 "0000004447" 34088
    2012 "0000004447" 773910
    2012 "0000004447" 1090012
    2012 "0000004447" 879764
    2013 "0000004447" 313807
    2013 "0000004447" 879764
    2013 "0000004447" 1163165
    2013 "0000004447" 797468
    2013 "0000004447" 1306965
    2013 "0000004447" 773910
    2013 "0000004447" 717423
    2013 "0000004447" 93410
    2013 "0000004447" 34088
    2013 "0000004447" 1140625
    2013 "0000004447" 101778
    2013 "0000004447" 201283

    As an example, for the fiscal year 2012, the company with cik identifier 0000004447 has 15 different peers (different peercik code). In 2013 the same company (cik=0000004447) has 12 different peers. It is possible dat a peer group do not change over the years, but I'am looking at those peergroups that do change.

    Now, I would like to create two dependent variables indicating whether a peer firm is 'added' to the peer group or 'dropped'. I want to express both dependent variables as a dummy variable. For the added dummies this means that the dependent variable is equal to 1 if the peer firm is added to the peer group in fiscalyear X and 0 otherwise.
    For the dependent variable dropped this means that the dependent variable equals 1 if the peer firm is excluded the next fiscalyear and 0 otherwise.

    My question is, how would I compute this in STATA?

    Thank you for your time.










  • #2
    Hi Maria,

    I'm not sure if I fully understand what you're up to. Anyways, how about this?
    Code:
    clear
    input double fiscalyear str12 cik double peercik
    2006 "0000002488" 932787
    2006 "0000002488" 703360
    2006 "0000002488" 70530
    2006 "0000002488" 1129446
    2006 "0000002488" 97476
    2006 "0000002488" 1272547
    2006 "0000002488" 791915
    2006 "0000002488" 50863
    2007 "0000002488" 703360
    2007 "0000002488" 791915
    2007 "0000002488" 70530
    2007 "0000002488" 50863
    2007 "0000002488" 97476
    2007 "0000002488" 932787
    2007 "0000002488" 1272547
    2015 "0000002969" 884905
    2015 "0000002969" 915389
    2015 "0000002969" .
    2015 "0000002969" 313616
    2015 "0000002969" 79879
    2015 "0000002969" 30554
    2015 "0000002969" 76334
    2015 "0000002969" 31462
    2015 "0000002969" 29905
    2015 "0000002969" 1306830
    2015 "0000002969" 1024478
    2015 "0000002969" 1307954
    2015 "0000002969" 49826
    2014 "0000004127" 1045810
    2014 "0000004127" 1097864
    2014 "0000004127" 6281
    2014 "0000004127" 827054
    2014 "0000004127" 895419
    2014 "0000004127" 763532
    2014 "0000004127" 316793
    2014 "0000004127" .
    2014 "0000004127" 913885
    2014 "0000004127" 743988
    2014 "0000004127" 791915
    2014 "0000004127" 743316
    2014 "0000004127" 1054374
    2014 "0000004127" 310568
    2014 "0000004127" 1036960
    2014 "0000004127" 791907
    2014 "0000004127" 768251
    2015 "0000004127" 310568
    2015 "0000004127" 1272547
    2015 "0000004127" .
    2015 "0000004127" 1045810
    2015 "0000004127" 743988
    2015 "0000004127" 1054374
    2015 "0000004127" 1097864
    2015 "0000004127" 827054
    2015 "0000004127" 743316
    2015 "0000004127" 768251
    2015 "0000004127" 763532
    2015 "0000004127" 791907
    2015 "0000004127" 6281
    2015 "0000004127" 1036960
    2015 "0000004127" 895419
    2005 "0000004281" .
    2005 "0000004281" 4285
    2005 "0000004281" 1171264
    2005 "0000004281" 1003467
    2005 "0000004281" 889211
    2005 "0000004281" 900268
    2005 "0000004281" 863064
    2006 "0000004281" 1171264
    2006 "0000004281" 863064
    2006 "0000004281" 889211
    2006 "0000004281" .
    2006 "0000004281" 900268
    2006 "0000004281" 4285
    2012 "0000004447" 717423
    2012 "0000004447" 101778
    2012 "0000004447" 1306965
    2012 "0000004447" 93410
    2012 "0000004447" 313807
    2012 "0000004447" 821189
    2012 "0000004447" 1140625
    2012 "0000004447" 201283
    2012 "0000004447" 1163165
    2012 "0000004447" 797468
    2012 "0000004447" 6769
    2012 "0000004447" 34088
    2012 "0000004447" 773910
    2012 "0000004447" 1090012
    2012 "0000004447" 879764
    2013 "0000004447" 313807
    2013 "0000004447" 879764
    2013 "0000004447" 1163165
    2013 "0000004447" 797468
    2013 "0000004447" 1306965
    2013 "0000004447" 773910
    2013 "0000004447" 717423
    2013 "0000004447" 93410
    2013 "0000004447" 34088
    2013 "0000004447" 1140625
    2013 "0000004447" 101778
    2013 "0000004447" 201283
    end
    
    * pre-save sort order
    tempvar sortorder
    generate `sortorder'=_n
    
    * mark first occurence of peercik per cik
    bysort cik peercik (fiscalyear) : generate added=(_n==1)
    
    * mark last occurence of peercik per cik
    bysort cik peercik (fiscalyear) : generate dropped=(_n==_N)
    
    * re-sort in original sort order
    sort `sortorder'
    It generates a dummy added that is 1 for the first occurence of each peercik inside of a cik, 0 otherwise. And a dummy dropped that is 1 for the last occurence of each peercik inside of a cik, 0 otherwise.

    Is that what you need?

    Kind regards
    Bela

    PS: Please have a look at the FAQ, also linked at the top of each page, in order to learn how to post well readable data examples. Using -dataex- was a good start (thanks!), but your question will be even better when using [CODE] delimiters.

    PPS: If you do not want added / dropped peercik's in the very first / last observed year per cik to be marked, add the following code before restoring the sort order:
    Code:
    * dis-mark first year per cik ("naturally" added==1)
    bysort cik (fiscalyear peercik) : replace added=0 if added==1 & fiscalyear==fiscalyear[1]
    
    * dis-mark last year per cik ("naturally" dropped==1)
    bysort cik (fiscalyear peercik) : replace dropped=0 if dropped==1 & fiscalyear==fiscalyear[_N]
    Last edited by Daniel Bela; 12 Jun 2018, 09:33. Reason: added PPS

    Comment

    Working...
    X