Announcement

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

  • Issue with calculating rolling betas for 36 months period

    Hi, hope this question and description is easy to comprehend

    I have gathered data for monthly returns for 49 industries from 2007 - 2018, as well as risk free rate (rf) and market returns, I wish to calculate a rolling beta for a 36 month window.

    First issue:
    The dates is formatted as 200701, 200702,...., 201812 with no days. How can I create a variable so stata recognizes it as months to create a window(36)

    Second issue:
    What would be the most reasonable code to use? I have been trying "rolling" but the the time variable seem to make it all messed up

    Thank you in advance

  • #2
    There are hundreds of similar posts here, so do look around for advice. rangestat (SSC) and asrol(SSC) are alternatives to rolling.

    On the specific detail of the dates. monthly dates are available through e.g.

    Code:
    gen mdate = ym(floor(date/100), mod(date, 100))
    format mdate %tm
    or some similar recipe depending on your unstated variable name.
    Last edited by Nick Cox; 04 Feb 2020, 09:25.

    Comment


    • #3
      Hello,

      Thank you for your help, the Code really helped with handling my data.

      For the rolling part, I found a lot of help here (if someone else encounters the same problem):
      https://www.statalist.org/forums/for...ow-regressions

      Comment

      Working...
      X