Announcement

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

  • Portfolio construction Fama & French

    Hello

    This is not only a question about a code and you probably need to know the paper "A five-factor asset pricing model" but maybe somebody can help me anyway.

    How did FF assign each stock to one of the 25 Size-BM, Size-OP & Size-Inv portfolio groups at the end of each June?

    I already created the relevant variables (Book-to-market, operating profitability, investment, and additionally momentum).

    Code:
    ** generate book-to-market ratio
    generate bm = e/mv
    
    ** generate operating profitability
    generate op = (s-cogs-i-sga)/e
    
    ** generate investment
    by company: gen inv = (ta- ta[_n-12])/ta[_n-12]
    
    ** generate momentum
    by company: gen mom = (mv[_n-1]/mv[_n-13])-1
    
    ** sort for 5 size and 5 B/M-, op-, inv-, & mom-groups
    egen size_group = xtile(mv), by(date2) p(20 40 60 80)
    egen bm_group = xtile(bm), by(date2) p(20 40 60 80)
    egen op_group = xtile(op), by(date2) p(20 40 60 80)
    egen inv_group = xtile(inv), by(date2) p(20 40 60 80)
    egen mom_group = xtile(mom), by(date2) p(20 40 60 80)
    My code assigns each stock at each month to one portfolio group. What I think I have to do, is evaluate at the end of each June if the portfolio group the stock is assigned to changes. But until then, the stock must remain in the assigned group.

    I already tried something with this code to use the month.
    Code:
    gen month = month(date2)
    If you have any idea how to solve the problem, I would really appreciate your help.

    Thanks in advance!

    Pascal


  • #2
    Hey Pascal,
    Have you used monthly data for creating operating profitability and investment? Can we use annual data too to create these variables?

    Comment


    • #3
      It is hard to correct a middle portion of Fama and French code without seeing the sequence of the code and structure of the data. However, I have few observations on what you have shown. Your research design might be different. However, the standard procedure for constructing Fama and French factors is way different than what your code tries to do. First of all, assignment of stocks to portfolios is done from July to June (see my blog post here) (Your code seems to do it by months if date2 is a monthly variable. Second, you are using explicit subscripts while calculating the investment variable, which might be incorrect if there is any missing month in the data. Third, you are finding momentum from market value (why not from share price which is not affected by increase / decrease in number of shares.
      Regards
      --------------------------------------------------
      Attaullah Shah, PhD.
      Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
      FinTechProfessor.com
      https://asdocx.com
      Check out my asdoc program, which sends outputs to MS Word.
      For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

      Comment


      • #4
        Hey Mehak,
        I have an entry for each month but it stays the same for one year, which is what I would like to have I guess.

        Comment


        • #5
          Professor Shah
          Thank you very much for your hint regarding the investment and momentum factor. I adjusted my data such that it looks the same as in your blog post. (I have one additional variable "company"). Explained with your data: How can I compute BE/ME such that 467/958 remains the same for the period June 2017 until May 2018?

          Comment


          • #6
            Hey Pascal, I have messaged you my query.

            Comment


            • #7
              Hi Mehak, Could you message me your query too?

              Comment


              • #8
                So what we do is create a variable called sort_date, this variable will contain the 1st date of July of each year (we do July because portfolios are held from July of year t till June of t+1). This variable is also going to be generated in market equity and other variables. Connecting both these data will be on the basis of permno and sorting_date.
                gen mofd=mofd(month)+1
                format mofd %tm

                gen sort_date = mdy(month(dofm(mofd)),day(month),year(month))
                format sorting_date %td

                For more information check this and this link.

                Comment

                Working...
                X