Hi there,
I'm trying to compute coefficient estimates using rolling regressions on daily CRSP stock data at monthly intervals. Specifically, I'd like to start the regressions on the first day of each new month and use the daily observations for each of the prior six months. The output I'm looking for is a single coefficient estimate for each month.
Here's my first take on the code:
The data only contains trading days, not calendar days, so 126 is the average number of trading days per six month period, and 21 is the average number of trading days per month. The goal here is to compute beta estimates once per month using all of the daily observations over the prior six months.
The problem with this is that there aren't exactly 126 trading days per six months, nor are there exactly 21 trading days per month. Is there a way to make this estimation more precise? For instance, on 01Jul2014, I would like the code to execute from 01Jan2014 to 30Jun2014, then step to 01Aug2014 and execute on 01Feb2014 to 31Jul2014, etc.
I've also looked up variants of ''rolling'' such as rolling2 and rollreg, but don't see any of them being flexible enough to do this. The solution might involve ditching ''rolling'' and writing custom loops.
Any and all help much appreciated!
I'm trying to compute coefficient estimates using rolling regressions on daily CRSP stock data at monthly intervals. Specifically, I'd like to start the regressions on the first day of each new month and use the daily observations for each of the prior six months. The output I'm looking for is a single coefficient estimate for each month.
Here's my first take on the code:
Code:
rolling _b, window(126) stepsize(21): reg excess_ret MKT
The problem with this is that there aren't exactly 126 trading days per six months, nor are there exactly 21 trading days per month. Is there a way to make this estimation more precise? For instance, on 01Jul2014, I would like the code to execute from 01Jan2014 to 30Jun2014, then step to 01Aug2014 and execute on 01Feb2014 to 31Jul2014, etc.
I've also looked up variants of ''rolling'' such as rolling2 and rollreg, but don't see any of them being flexible enough to do this. The solution might involve ditching ''rolling'' and writing custom loops.
Any and all help much appreciated!
Comment