Announcement

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

  • Creating quartiles on a panel data set based on a variable's value in one period

    Hello all,

    I want to do something pretty theoretically simple (that I used to do myself, but have completely blanked on how to do). I have a panel data set, and I want to create quartiles based on the value of the outcome variable in the period before treatment. The point is to track whether treatment affected units in different quartiles differently, so I want the value of the quartile variable to be the quartile on the period before treatment in all periods (for all observations within a unit). I don't want to create quartiles per period, I want to create quartiles in one period and get the quartile in that period to show as the value of the quartile variable across all periods.

    Thank you in advance for any help provided. I don't include a data sample because I don't think it's necessary as this is a general question, but I can add one if need be.

  • #2
    This could mean several different things. Ambiguities are everywhere.

    I think you want to assign quartile bins, rather than calculate quartiles main and historic sense.

    The assignment should be based on an early period and carried across to a later period.

    But how are you going to do this unless each entity has a constant value in the early period?

    Here is a concrete example which may make clear that you really want something quite different.

    Code:
    webuse grunfeld, clear
    
    egen median = median(invest) if year < 1940 , by(company)
    
    xtile median4=median, nq(4)
    
    bysort company (median4) : replace median4 = median4[1]
    Here there are 10 companies, so we can't do better than 2 or 3 in each bin.

    Comment

    Working...
    X