Announcement

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

  • SSC astile - how to get difference of High minus low portfolio ?

    Hi there,

    I am using the below example to explain my query. I am able to create portfolios successfully via astile and can see the quintile portfolios in "size5" column. Now I want to create a new variable "Difference" that gives the difference of size5 quintiles (5 - 1) within each year for "invest" variable.

    there are the same ranks within a year for companies in the size5 column and I want the difference of quintile5 and quintile1 for "invest" variable. Please advise how I can do that?


    Code:
    webuse grunfeld
    bys year: astile size5=mvalue, nq(5)

    regards, Sara

  • #2
    By the difference between quintiles here perhaps you have in mind something more like the difference between means for quintile bins.

    Assuming that astile (SSC) assigns 1 and 5 respectively to observations in top and bottom bins (and not ranks, as you state), then you can get the means by

    Code:
    egen bin1 = mean(cond(size5 == 1, mvalue, .) , by(year) 
    egen bin5 = mean(cond(size5 == 5, mvalue, .),  by(year)
    after which

    gen diff = bin5 - bin1
    egen tag = tag(year)


    and many (but not all) analyses of diff should be carried out if tag to ensure that just one value is considered for each year


    If this is off-target, you need the help of someone familiar with astile, perhaps Attaullah Shah himself. On the other hand, if you want some summary statistic other than the mean, then the logic is similar

    Comment


    • #3
      Hello Nick, Thanks for the code. yes, I am looking at the difference between the means for quintile bins. I tried the code you provided and it worked. Thanks, heaps for your help.

      Regards, Sara
      Last edited by sara haris ali; 06 Dec 2021, 11:19.

      Comment


      • #4
        My typo, but the logic that parentheses should be balanced should make the correct answer easy to guess.

        Code:
        mean(cond(size5 == 1, mvalue, .))  
        and so on.

        Comment

        Working...
        X