Announcement

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

  • Create comparison between firm-years

    Hi all,

    I am trying to create a regression model, but fail to find the right way to modify the data so i can perform my regression correctly.
    I have a database of 36.000 firm-year observations, with approximately 10 years of observations per firm. The names with which the firm-years are identified is (FYEAR) and the names for the specific companies are defined by the variable (COMPANYCODE1).

    The database contains a binary variable (ICMW) which only presents a 1 for certain firms and firm-years.

    The 2 problems i am stuck with are as follows:

    1. I want to perform a regression which compares (per company) the firm-years before the variable ICMW presents a 1 and the firm-years after.
    But i can't seem to find the code for letting Stata perform a comparison between the yearly data of a company, with the ICMW-variable as border.

    2. I only want to perform the regression for firms that actually contain a 1 for ICMW in one or more years. But Stata keeps dropping observations of all yearly-observations without a 1 for ICMW, while i only want to drop all companies (so all the yearly observations of companies) without a 1 for the ICMW. For this problem, i have been jumbling with panel data, but i haven't found the right solution yet.

    I would want to provide you with the code for this problem, but seeing as i haven't been able to find it, i can't post it either.

    I hope i provided enough information for you guys to understand the problem! If anyone knows a solution to my problem, it would be much appreciated!

    Kind regards

    Max


  • #2
    To the extent that I understand your task:
    Code:
    sort idfirm year
    by idfirm: egen suitable=total(icmw)
    generate byte ba=.
    by idfirm : replace ba=cond(_n==1,icmw,ba[_n-1]+icmw) if suitable
    regress y x icmw ba
    I assumed that
    1. icmw event occurs no more than once for each firm in the observation window
    2. that icmw takes value of 0 everywhere, where it is not 1.
    3. The period where icmw occurs is joined with the periods after the event.
    I felt the description is not precise for the case of multiple events. You may want to clarify that and modify the above code.
    I am equally not sure if the window may be only a single year or if the event may occur in the first period of observation, in which case the before group is zero-sized.

    Comment


    • #3
      I tried and modified a bit on the code you provided, it works now! Thank you Sergiy. Now i can move on with my research!

      Comment

      Working...
      X