Announcement

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

  • Issues with rolling regression

    Hi all, I am trying to do a 36 month rolling regression analysis where I would like to store the residuals of each regression as a new time series variable. In my mind, I would then have 36 observations with residuals from each regression in a new variable that I could use for further analysis. I am having trouble as it seems the 'residual variable' contains no values in the new file that is generated (see code below). Does anyone know why?
    Please note, I am VERY new to STATA, so apologies if this is a dumb question or I am leaving out anything obvious

    For further clarification:
    The rolling regression is a 36 month window where i regress stock returns of a company on Fama-French five factor model.

    Here is my input:

    tsset date

    rolling _b _se resid=e(resid), window(36) saving(rolling_resid, replace): regress stock_returns mktrf smb hml rmw cma

    Thanks!

  • #2
    There is no statistic "e(resid)" that is generated from running regress. I don't understand what you are trying to do here. If you are predicting the residuals, then these are observation specific. The sum of OLS residuals is always equal to zero, in case you want one value.

    Code:
    regress stock_returns mktrf smb hml rmw cma
    predict res, res
    Last edited by Andrew Musau; 14 Mar 2024, 06:24.

    Comment


    • #3
      In principle you need a new variable for each regression, as the windows overlap as they move. There isn’t to me an obvious sense in which the residuals can be stored in one variable.

      This is statistical principle and not a Stata point.

      Comment

      Working...
      X