Dear users of Stata,
I am working with panel data (approx. 1.3 million observations, 18 variables) on daily stock prices for approx. 5,500 firms over a time period of one year. I have encountered the following problem:
I want to generate a variable with one observation per day and per firm that reports the autocorrelation between the daily stock return and its first lag, over the last 20 trading days (i.e. a moving window). That is, I do not want to generate a variable reporting the autocorrelation of daily stock returns over the entire observation period.
Unfortunately, I have not been able to find a solution with my own limited skills or in prior posts by other users. Accordingly, I would greatly appreciate any input or advice you might be able to provide.
Thanks in advance and best,
Martin
I am working with panel data (approx. 1.3 million observations, 18 variables) on daily stock prices for approx. 5,500 firms over a time period of one year. I have encountered the following problem:
I want to generate a variable with one observation per day and per firm that reports the autocorrelation between the daily stock return and its first lag, over the last 20 trading days (i.e. a moving window). That is, I do not want to generate a variable reporting the autocorrelation of daily stock returns over the entire observation period.
Unfortunately, I have not been able to find a solution with my own limited skills or in prior posts by other users. Accordingly, I would greatly appreciate any input or advice you might be able to provide.
Thanks in advance and best,
Martin
Comment