Announcement

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

  • Problem with generating a "rolling window" for a regression involving Stock returns

    Dear all,

    I recently started using Stata since I need to conduct some calculations for my Bachelorthesis.

    I now wanted to calculate the excess return of certain stocks by performing a regression with several variables. Each regression should be estimated by using a 36 month rolling window.

    My data is all in one excelsheet and looks like this:
    Click image for larger version

Name:	Stata_Picture.png
Views:	1
Size:	36.1 KB
ID:	1753452


    The data ranges from 29.1.1965 to 29.12.2006

    The command I used for stata is the following:
    1. "tsset Date"
    2. "rolling, window(36) clear: reg EXCOMP VWRF SMB HML MOM"
    The command is then executed but the only result I got is the following Error:
    "x: Error occurred when rolling executed regress."

    Since I am relatively new to Stata so I could not figure it out on my own.

    It would be of great help if someone in this Forum could help me. If I have to provide more information just let me know.

    Thank you all very much in advance!

    Sincerely
    Dennis Küchle

  • #2
    Would you ask a question about Excel in an Excel forum showing what the data look like in Stata?

    Please read through the FAQ Advice (especially #12) and use dataex to show us what the data look like in Stata. It's possible that the data have not been imported correctly.

    The most obvious problem here to me is that you have monthly data indexed by daily dates. So, each window of length 36 (days!) contains only 2 observations at most from which to estimate 5 parameters in a regression. That won't work.

    So, at least one step is to convert the dates into a monthly date variable.

    Comment


    • #3
      Hello Nick,
      first of all, thank you for your fast reply.

      I am sorry for not reading the FAQ first.
      I just saw another answer from you referring to the command "help datetime".
      Additionally, you mentioned this code in one of your previous answers:

      "gen Mdate = mofd(Date)
      format Mdate %tm"

      I think that already fixed my problem since the output for "rolling, window(36): reg EXCOMP VWRF SMB HML MOM" now looks like this:
      Click image for larger version

Name:	Screenshot 2024-05-16 100815.png
Views:	1
Size:	38.6 KB
ID:	1753512


      Thank you very much!

      Sincerely
      Dennis

      Comment

      Working...
      X