Dear all,
I just started to use Stata, so I don't have much knowledge about it. I need to calculate the capm beta (market beta) for 524 different stock over a time period from 31.12.1991 to 30.12.2016.
I have the daily stock and market excess returns xdr_ and xdrm_ for each date in the long format, as follows:
In the first colum: variable date from 31.12.1991 to 30.12.2016
In the second colum: Stock ids from 1 to 524
And in the next colums the exess returns.
I want to estimate the betas with a rolling regression of exess returns on market excess returns. The general formula for beta is given by beta=Corri,m(sd(i)/sd(m)) where sd(i) and sd(m) are the estimated volatilities for the stock and the market and corri,m is their correlation. I am looking for monthly betas as I need to rebalance later portfolios by the change of betas, that is why I set the window as 31.
As I was looking for solutions in Stata help and Statalist forums I found this code:
The problem is that our varibales include a lot of missing data, with which rolling is not working, so we converted all missing data to 0s. Now we are afraid to generate a big bias. Furthermore, we are not quite sure, if this formula is correct.
Could you help me with myproplem and maybe suggest codes which could calculate the beta I am searching for? Or do Ihave to calculate the sd and corr sperately and calculate the beta with these values? If so, could you also help me with that? I tried long time to solve this problem, but I didnt succeed.
Thank you so so much for your help in advance.
I just started to use Stata, so I don't have much knowledge about it. I need to calculate the capm beta (market beta) for 524 different stock over a time period from 31.12.1991 to 30.12.2016.
I have the daily stock and market excess returns xdr_ and xdrm_ for each date in the long format, as follows:
In the first colum: variable date from 31.12.1991 to 30.12.2016
In the second colum: Stock ids from 1 to 524
And in the next colums the exess returns.
I want to estimate the betas with a rolling regression of exess returns on market excess returns. The general formula for beta is given by beta=Corri,m(sd(i)/sd(m)) where sd(i) and sd(m) are the estimated volatilities for the stock and the market and corri,m is their correlation. I am looking for monthly betas as I need to rebalance later portfolios by the change of betas, that is why I set the window as 31.
As I was looking for solutions in Stata help and Statalist forums I found this code:
cd "\\cfs-student.student.uni-augsburg.de\homes\Eigene Dateien\International Finance and Banking"
tsset stockss date
foreach s of varlist stockss {
rolling _b, window(31) saving(betas, replace): regress xdr_ xdrm_ if stockss == `s'
}
tsset stockss date
foreach s of varlist stockss {
rolling _b, window(31) saving(betas, replace): regress xdr_ xdrm_ if stockss == `s'
}
Could you help me with myproplem and maybe suggest codes which could calculate the beta I am searching for? Or do Ihave to calculate the sd and corr sperately and calculate the beta with these values? If so, could you also help me with that? I tried long time to solve this problem, but I didnt succeed.
Thank you so so much for your help in advance.
Comment