Announcement

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

  • How can I keep firms have at least 2 years of pre and post-event financial data

    Hi,

    I have an unbalanced panel data, which firms have a different number of year-observations. However, for my research, I want to keep firms have at least 2 years of pre and post-event financial data. The year that event occurs is 0. One-year pre, two-year pre are -1 and -2, etc. One-year post, two-year post are 1 and 2, etc...

    Thank you very much in advance.

    Regards,
    Anh


  • Carlo Lazzaro
    replied
    Amelia:
    welcome to this forum.
    Please re-post your query on the General forum, as this one is intended for practising purposes only. Thanks.

    Leave a comment:


  • Amelia Azjahra
    replied
    Carlo Lazzaro

    Hi Carlo, i wanna ask you about panel data but not related to the one above.

    I have micro panel data with 15.689 observation in 7 years. when i run hausman test, the results is to reject the null-hypothesis.
    but, when i run Breusch-Pagan LM test, the results is also reject the null-hypothesis.

    I am confused, what is the best model for my data? because i have one time-invariant variable so it's impossible to use FEM.
    but i read from a book, if the true model is fixed effects, the random effects estimator is inconsistent.

    Thanks before

    Leave a comment:


  • Carlo Lazzaro
    replied
    Celine:
    please re-post your query to the General forum, as this one is intended for practising purposes only. Thanks.

    Leave a comment:


  • Celine Tran
    replied
    David Benson

    Hi David,

    Today, I am writing to ask you some questions related to the one above. If I want to keep firms have at least two firm-year observations before and after an event with ignoring the consecutiveness of year, what should I do?

    For example:

    Code:
           id      year
      1. 1 -2
      2. 1 -1
      3. 1 0
      4. 1 1
      5. 1 2
      6. 1 3
      7. 1 4
      8. 2 -4
      9. 2 -2
     10. 2 0
     11. 2 1
     12. 2 2
     13. 3 -1
     14. 3 0
     15. 3 1
     16. 3 2
     17. 3 3
     18. 4 -4
     19. 4 -1
     20. 4 0
     21. 4 1

    I want to keep firm 1 and firm 2 because they have at least two firm-year observations around year =0.

    Thank you very much in advance !
    Last edited by Celine Tran; 29 Nov 2019, 22:08.

    Leave a comment:


  • Celine Tran
    replied
    Dear David,

    Thank you very much. I have saved me . The code works through.

    Regards,
    Anh.

    Leave a comment:


  • David Benson
    replied
    Hi Celine,

    Actually, I think that second set of code should work (with one modification):

    Code:
    bysort id: egen first_year = min(year)
    bysort id: egen last_year = max(year)
    gen to_keep=1 if first_year<=-2 & last_year>=2  // in your example above, to_keep==1 for firms 1 & 2, and missing for 3 & 4
    
    * I don't like to drop things until I know it is what I want, once you've verified everything:
    keep if to_keep==1
    I've also posted the dataex stuff so you can copy and paste this to the General Forum page.
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(id year)
    1 -2
    1 -1
    1  0
    1  1
    1  2
    1  3
    1  4
    2 -3
    2 -2
    2 -1
    2  0
    2  1
    2  2
    3 -1
    3  0
    3  1
    3  2
    3  3
    4 -3
    4 -2
    4 -1
    4  0
    4  1
    end

    Leave a comment:


  • Celine Tran
    replied

    Dear David,

    Thank you very much for your help. However, it is not the one I need. I would like to investigate, for example, firm performance before and after an event (such as, global crisis - year 0). My sample is unbalanced, however I need that each firm must have at least two-year financial data before and after that event. Therefore, firms which have only one-year before event and more than one-year financial data; or more than one-year before event and only one-year after event, must be remove. Please ignore missing value.


    For example: My sample is something like that:

    id year
    1 -2
    1 -1
    1 0
    1 1
    1 2
    1 3
    1 4
    2 -3
    2 -2
    2 -1
    2 0
    2 1
    2 2
    3 -1
    3 0
    3 1
    3 2
    3 3
    4 -3
    4 -2
    4 -1
    4 0
    4 1

    I want to keep only firm id1 and firm id 2 because they have at least two-year financial data around year 0. Firm id 3 and 4 should be dropped from my sample because it has only one-year financial data before year 0 and only one-year financial data after event, respectively.

    Thank you very much.
    Last edited by Celine Tran; 28 Oct 2018, 01:56.

    Leave a comment:


  • David Benson
    replied
    There is probably a few ways to do this (I'd have to see a copy of what your data looks like to get this to work:
    1. Do all firms that have at least 5 yrs of data have -2, -1, 0, 1, and 2? (Or could a firm have 5 yrs of data, but enter at event_year==+2?). If it's the first, then you could do something like this
    Code:
    bysort firm_id (year): gen years_in_data = _N  
    drop if years_in_data < 5
    * NOTE: Above I assume year is an event_year (-2, -1, 0, +1, +2, etc), not 2005, 2006, 2007, etc
    2. Alternatively, if a firm is in your sample at event_year==-2 and event_year==+2 does that mean it is also in your data for all years in between (i.e. it somehow isn't missing -1 or +1 so something like that?

    Code:
    bysort firm_id: egen first_year = min(year)
    bysort firm_id: egen last_year = max(year)
    keep if first_year<=-2 and last_year>=2 & last_year!=.
    Hope that helps!
    Last edited by David Benson; 27 Oct 2018, 23:27.

    Leave a comment:

Working...
X