Announcement

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

  • Regression on Variable -> Creating Portfolios - Calculate average Portfolio return

    Hello,

    I´m a totally newbie in Stata and last time many people from this forum supported me and provided me the perfect code I required for my analysis. Therefore I would ask for help again.

    I have daily stock data for different firms (pannel data). Now want to run each day a regression for all companies (permno) returns (ret) against the variable VRP for the last 12 month or for the last 252 trading days. Afterwards I want to sort all stocks into five portfolios according to their sensitivities to the variable VRP (ßVRP or b_VRP). Finally I want to calculate the equally weighted return of each portfolio. The whole process shuld be rolling: So each day first run the time series regression based on the last 12 Months), than rank the stocks accoriding to their risk sensitivity to VRP into 5 portfolios and finally calculate the average daily return for each portfolio.

    My variables are labled as follows:

    daily stock return : ret
    copany identifier: permno
    time series defined by date
    Variance Risk: VRP

    I would be very happy if someone could provide me the code for my problem. I appreciate your effort in the first place.

    Kind regards

    Steven

  • #2
    That's a request for code for an entire project. Someone may be very happy to provide you with that, but my guess is that you're asking too much.

    Meanwhile there are hundreds of posts here on analyses of stock returns, so you should be able to cobble together most of what you need by reading carefully.

    There is a fine line between a helpline and a discussion forum. On a helpline individual attention is an expectation, even if the answer is No. On a forum the posts remain visible as a resource for others, and you're expected to look around a bit, and no one has to answer anything.

    Comment


    • #3
      Nick is right, as usual. But let me get you started on the part that, in most situations, would be considered the hardest.

      You can do the rolling regressions as a one-liner with the -rangestat- command:

      Code:
      rangestat (reg) ret VRP, by(permno) interval(date -366 -1)
      Notes:
      1. To run this you need the -rangestat- command, written by Robert Picard, Nick Cox, and Roberto Ferrer, available from SSC.
      2. I assume your date variable is a Stata internal format date variable. If it is not, you need to convert it to one. See -help datetime-.
      3. I assume that by "last 12 months" you mean the interval that begins 366 days earlier and ends 1 day earlier. If you want the period to include "today" then change that -interval()- option to -interval(date -365 0)-.

      From there, I endorse Nick's suggestion that you search the forum for previous posts on similar problems to see how to create the portfolios and calculate their returns.

      Comment


      • #4
        Mr. Cox I`m with you and I exactly know what you mean. I dont expect anyone to help my, I was just asking. I just startedt to work with Stata and barely understand Stata`s syntax. Furthermore I thought my issue is an common one and it´s maybe for someone just a copy paste of their do-file. I don`t expect anyone to spend hours to solve my problem. I´m also reading a lot in this forum which helps me a lot but sometimes cobbling things togethers creates ne problems and errors since I dont understand the systax for 100% - as I said I´m just a beginner. Usually I would solve such problems by trying and trying. Since I need my calculations for my thesis which is due in ten weeks I´m a little bit stressed =). But I will keep on going and hopeflully I´m not bothering someone with my queries and questions.

        Thank you very much Mr. Schechter for your support. I think this gets me started!

        Kind regards

        Steven

        Comment


        • #5
          For the portfolio part, you can read my blog post that shows how to do it using astile program (available from SSC). You can also look at the asreg program (also available from SSC) that estimates rolling window regressions, by-groups regressions, and Fama & MacBeth (1973) regressions. Just like the Stata official xtile command, astile creates a new variable containing quantile categories. The following lines of codes will take you closer to what you want. Since there is no data to play with, the following codes might need some adjustments.

          Code:
          ssc install astile
          ssc install asreg
          
          bys permno: asreg ret VRP, wind(date 365)
          bys date : astile P5 =_b_VRP, nq(5)
          bys P5 date : egen Rp = mean(ret)
          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


          • #6
            Thank you very much Mr. Sah.

            Comment

            Working...
            X