Hi all,
I am trying to code a rolling beta. The situation is as follows: The time period is 2014-2019 and I am trying to find the betas of each stock at the beginning of the month based don't the previous year of daily observations, resulting in 60 betas per company in the dataset. Do you have any idea how I do this regression? I have tried to code it in a variety of ways but am finding it difficult to run the regression only for the beginning of the month, and as my dataset is rather large (10 million observations) any tips to run the regression faster would also be appreciated. I have done all of the prep work: I have the year_month categorized, and have a variable for start of the month. I just do not know how to incorporate it as the if function is not compatible. I currently have used this but it doesn't seem to solve the issue. * Adjust the rolling command to run only on the first of each month
rolling beta = _b[market_excess_return], window(252) saving(rolling_beta, replace) if first_of_month == 1: ///
regress excess_return market_excess_return if date >= date[_n-251]
Thanks in advance
Lucas
I am trying to code a rolling beta. The situation is as follows: The time period is 2014-2019 and I am trying to find the betas of each stock at the beginning of the month based don't the previous year of daily observations, resulting in 60 betas per company in the dataset. Do you have any idea how I do this regression? I have tried to code it in a variety of ways but am finding it difficult to run the regression only for the beginning of the month, and as my dataset is rather large (10 million observations) any tips to run the regression faster would also be appreciated. I have done all of the prep work: I have the year_month categorized, and have a variable for start of the month. I just do not know how to incorporate it as the if function is not compatible. I currently have used this but it doesn't seem to solve the issue. * Adjust the rolling command to run only on the first of each month
rolling beta = _b[market_excess_return], window(252) saving(rolling_beta, replace) if first_of_month == 1: ///
regress excess_return market_excess_return if date >= date[_n-251]
Thanks in advance
Lucas
Comment