Announcement

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

  • Coding problem Multiple Events Dif-in-Dif with Panel data

    Hi all,

    Currently writing my master thesis and unfortunately I am unable to find an answer to my question. I have a Compustat panel dataset with events (M&A activity) and I am trying to do a Dif-in-Dif analysis, and therefore I would like to keep only those years that are needed for the event window, which is in my case y-3 to y+3 (7 years). The goal is to investigate the effect of M&A on a firm variable by comparing 3 years before and 3 years after the event (M&A activity).

    Of course some events have overlapping event windows, as some mergers occur within 3 years of each other. I would only like to keep the event if the event does not have overlap in the period y-3. Overlap in y+3 is OK for me, but this does imply that the second event has overlap in y-3 and should be excluded.

    Data
    Paneldata with fyear for time and gvkey as firm identifier
    Event = 1 (tag)

    Goal
    Only keep events and panel for which y-3 and y+3 is available (7 years in total, including year of event) and exclude all events with eventwindow overlap in y-3 or where this event window is not available in the dataset.

    I am open for suggestions if there is a better way of doing this. Hopefully someone can give me a direction or solution as I have been trying to code this for days and do not see how I can do this with STATA.

    Thanks in advance!

    Tom



  • #2
    I tried the following, but it limits me in only selecting the first and the last event for a certain company, while I would like to keep all events that have a good event window. It also does not allow me to exclude events where y-3 to y+3 is not complete when >1 events take place for a given gvkey..

    Code:
    sort gvkey fyear
    *** I exclude event if another event lies in y-3 by making this event = 0.
    by gvkey: replace event = 0 if event[_n-1] == 1
    by gvkey: replace event = 0 if event[_n-2] == 1
    by gvkey: replace event = 0 if event[_n-3] == 1
    by gvkey: replace event = 0 if missing(event)
    
    by gvkey: gen datenum=_n
    by gvkey: gen target=datenum if event ==1
    bysort gvkey (datenum) : drop if datenum[_N]<7
    
    egen td=min(target), by(gvkey)
    egen td2=max(target), by(gvkey)
    drop target
    gen dif1=datenum-td
    gen dif2=datenum-td2
    
    drop td td2 datenum
    
    drop if dif1 & dif2 >3
    drop if dif1 & dif2 <-3
    Last edited by Tom Vanderlaan; 05 Jul 2016, 08:50.

    Comment

    Working...
    X