DATA Step, Macro, Functions and more

Beta Estimation

Accepted Solution Solved
Reply
Contributor
Posts: 63
Accepted Solution

Beta Estimation

[ Edited ]

Hi everyone,

 

Can you please help me to estimate beta for this sample. The actual data is over 100 million observations; therefore, please kindly use the code that fits that huge data. We estimate following equation for each stock using daily returns within a month. For example for stock 1, we run the regression based on daily returns of January 2010 and for other months too. The equation is given below:

 

Return of each stock= C + beta1 (mkt1)+beta2 (mkt2) + beta3 (mkt3) +residual.

 

Then finally we estimate the beta based on sum of all three betas i.e.; beta = beta1+beta2+beta3

The data is given below:

data have;
infile cards expandtabs truncover;
input stock date : yymmdd10. ret mkt1 mkt2 mkt3 ;
format date yymmdd10.;
cards;
1	2010-01-07	0.04135	0.01	0.012	0.008
1	2010-01-26	-0.02544	0.02	0.024	0.016
1	2010-01-29	0.03384	0.03	0.036	0.024
2	2010-01-07	0.06069	0.01	0.012	0.008
2	2010-01-26	-0.06219	0.02	0.024	0.016
2	2010-01-29	0.01989	0.03	0.036	0.024
run;

Thanks a lot for your help.


Accepted Solutions
Solution
‎03-01-2017 06:01 AM
Super User
Posts: 10,023

Re: Beta Estimation

data have;
infile cards expandtabs truncover;
input stock date : yymmdd10. ret mkt1 mkt2 mkt3 ;
format date yymmdd10.;
cards;
1 2010-01-07 0.04135 0.01 0.012 0.008
1 2010-01-26 -0.02544 0.02 0.024 0.016
1 2010-01-29 0.03384 0.03 0.036 0.024
2 2010-01-07 0.06069 0.01 0.012 0.008
2 2010-01-26 -0.06219 0.02 0.024 0.016
2 2010-01-29 0.01989 0.03 0.036 0.024
;
run;
proc reg data = have outest=want noprint;
by stock date;
format date monyy5.;
model ret = mkt1 mkt2 mkt3;
run;

After get WANT table, it is easy to get beta you want.

View solution in original post


All Replies
PROC Star
Posts: 735

Re: Beta Estimation

data have;
infile cards expandtabs truncover;
input stock date : yymmdd10. ret mkt1 mkt2 mkt3 ;
format date yymmdd10.;
cards;
1 2010-01-07 0.04135 0.01 0.012 0.008
1 2010-01-26 -0.02544 0.02 0.024 0.016
1 2010-01-29 0.03384 0.03 0.036 0.024
2 2010-01-07 0.06069 0.01 0.012 0.008
2 2010-01-26 -0.06219 0.02 0.024 0.016
2 2010-01-29 0.01989 0.03 0.036 0.024
run;

proc reg data = have;
model ret = mkt1 mkt2 mkt3;
run;

Contributor
Posts: 63

Re: Beta Estimation

I am looking for three beta (beta1, beta2, beta3) values for each stock each month. Anyway Thanks for your time and efforts.
Solution
‎03-01-2017 06:01 AM
Super User
Posts: 10,023

Re: Beta Estimation

data have;
infile cards expandtabs truncover;
input stock date : yymmdd10. ret mkt1 mkt2 mkt3 ;
format date yymmdd10.;
cards;
1 2010-01-07 0.04135 0.01 0.012 0.008
1 2010-01-26 -0.02544 0.02 0.024 0.016
1 2010-01-29 0.03384 0.03 0.036 0.024
2 2010-01-07 0.06069 0.01 0.012 0.008
2 2010-01-26 -0.06219 0.02 0.024 0.016
2 2010-01-29 0.01989 0.03 0.036 0.024
;
run;
proc reg data = have outest=want noprint;
by stock date;
format date monyy5.;
model ret = mkt1 mkt2 mkt3;
run;

After get WANT table, it is easy to get beta you want.

Contributor
Posts: 63

Re: Beta Estimation

Thanks a lot ksharp, it works well.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 196 views
  • 2 likes
  • 3 in conversation