Announcement

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

  • Portfolio construction and regression

    Hi,

    So I have got monthly panel data of about 5000 firms over a period of about 10 years and need to construct equally weighted as well as value weighted top in class and bottom in class portfolios based on a sustainability measure. Afterwards I need to take the (equally weigthed or value weigthed) returns of those portfolios and regress the Fama &French factors against them. Since I am not very experience with stata I was wondering whether someone could help me with the commands to do so. Therefore I would need a command that select the returns of the top and bottom 25 % each month based on the sustainability variable followed by a mean command of those returns and then regressing them with three other varables. For the value weighted portfolios I would also need a command which would weighted each return by the fraction of this firms market value to the whole market value within that portfolio.


    Any help is highly appreciated
    Regards,

    Lutz

  • #2
    You can make the question less abstract by sharing an excerpt from your data. See section 12 in the FAQ for useful advice.

    Comment


    • #3
      Code:
       bysort date: egen portfolio_top= mean(RET), pctile( ESGSCORE), p(25)
      by Data basically looks like this:


      Date ID RETurns ESGSCORE MarketCAP

      200501 A 0.25 1.44 3.0e11
      200501 B 0.22 1.20 1.2e10
      200502 A 0.23 1.43 2.9e11
      200502 B 0.20 1.20 1.1e10


      I have got panel data for about 4500 companies ( number of companies each year varies). These companies are scored according to ESG measures which is the ESGSCORE variable.
      Now I want to construct portfolios EACH MONTH averaging the returns but selecting only the companies' returns given the ESGSCORE.. Hence in 200501 the Top and Bottom 25% of companies based on the ESGSCORE values.
      I tried the code above which doesnt work (Invalid p) maybe somebody can help.

      Comment


      • #4
        That's fantasy syntax. For example, you are combining two egen functions in a way that is quite illegal.

        You need to calculate the percentiles first, then means conditionally on those. See also http://www.statalist.org/forums/foru...nel-data-graph for a similar question.

        Code:
         
        bysort date : egen ESC25 = pctile(ESGSCORE], p(25)  
        by date : egen lower25 = mean(RET) if ESGSCORE < ESC25

        Comment


        • #5
          Thank you very much Nick Cox. The first part worked although now I get a type missmatch error for the second line

          Comment


          • #6
            ok got it now. needed to destring my RET thank you

            Comment

            Working...
            X