Announcement

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

  • Centiles with by option

    Dear All,

    I am currently working on a project, in which I want to calculate abnormal returns for a 1 year rolling portfolio of firms that have made a repurchase announcement
    the last 12 months based on their market value. So, I want to put each firm in a size quantile based on its market value regarding the market value of all firms in CRSP
    dataset in that particular month. As a first step I go to the CRSP full sample dataset and I put each firm to a quantile.

    I use the following code:
    gen MONTH = mofd(date)
    ssc install egenmore
    egen quants= xtile(market_val ), by(MONTH) nq(5)

    My question is how can I put my portfolio firms to the full sample quantiles.

    I thought to exctract centiles in each month for the full sample, however centile does not work with by.

    Thank you very much for your time and attention!!

    Kind regards,
    Ioannis Efraimidis
    Last edited by Ioannis Efraimidis; 07 Mar 2018, 03:14.

  • #2
    Quantiles are values defined by the probability of values being lower with small print about the precise definition given ties and how to calculate them from data.

    There is a common ellipsis to use the term also to refer to bins, classes or intervals those quantiles define, so that for example four quintiles defined for cumulative probabilities 0.2(0.2)0.8 define five bins.

    What I am missing here is some other sense: "full sample quantiles". As a simple example with the installation you mention you could get

    Code:
    . webuse grunfeld
    
    . egen bin = xtile(mvalue), by(year) nq(5)
    
    . tab year bin
    
               |                          bin
          year |         1          2          3          4          5 |     Total
    -----------+-------------------------------------------------------+----------
          1935 |         2          2          2          2          2 |        10 
          1936 |         2          2          2          2          2 |        10 
          1937 |         2          2          2          2          2 |        10 
          1938 |         2          2          2          2          2 |        10 
          1939 |         2          2          2          2          2 |        10 
          1940 |         2          2          2          2          2 |        10 
          1941 |         2          2          2          2          2 |        10 
          1942 |         2          2          2          2          2 |        10 
          1943 |         2          2          2          2          2 |        10 
          1944 |         2          2          2          2          2 |        10 
          1945 |         2          2          2          2          2 |        10 
          1946 |         2          2          2          2          2 |        10 
          1947 |         2          2          2          2          2 |        10 
          1948 |         2          2          2          2          2 |        10 
          1949 |         2          2          2          2          2 |        10 
          1950 |         2          2          2          2          2 |        10 
          1951 |         2          2          2          2          2 |        10 
          1952 |         2          2          2          2          2 |        10 
          1953 |         2          2          2          2          2 |        10 
          1954 |         2          2          2          2          2 |        10 
    -----------+-------------------------------------------------------+----------
         Total |        40         40         40         40         40 |       200
    We can't access your dataset (no doubt, it's very large) and you don't give a worked example of what you want instead, so can you spell it out in terms of a commonly accessible dataset?

    Your stated aim is

    Code:
    I want to put each firm in a size quantile based on its market value regarding the market value of all firms in CRSP
    dataset in that particular month
    and so far as I can see the code you cite does precisely that (with a choice of quintiles).


    Comment


    • #3
      Dear Dr. Cox,

      I want to create the quantiles in the full sample for every month(which include all CRSP firms) in order to extract the centiles of the these quantiles in order to put only my portfolio firms(a subset of full sample CRSP dataset) in new quantiles, but based on the full sample centiles.

      I hope I make it more clear.

      Kind regards,
      Ioannis Efraimidis

      Comment


      • #4
        That's clearer, but you need to provide an example, as already suggested. If you're expecting us to create an example and then think up code, someone might do that, but it is less likely than reacting to a precise example.

        Comment


        • #5
          Or -- what's wrong with this?

          1. Classify all firms.

          2. Throw away those not in your portfolio.

          Comment


          • #6
            Dear Dr. Cox,

            I just thought the same! With a merge with my portfolio dataset I will keep only the portfolio firms. However, now the problem is that firms are put in the quantiles not based on their current market value, but on their lagged market value.I will think how I can do that!

            Thank you so much for your quick and precise reply!!!

            Kind regards,
            Ioannis Efraimidis

            Comment

            Working...
            X