Solved
Contributor
Posts: 73

# 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,681

## 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.

All Replies
PROC Star
Posts: 1,209

## 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: 73

## 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,681

## 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: 73

## Re: Beta Estimation

Thanks a lot ksharp, it works well.
Contributor
Posts: 46

## Re: Beta Estimation

how do you get beta (PROC GLIMMIX Beta distribution) back on original scale?

PROC glimMIX;

CLASS Phase TRT DAY ID;

MODEL DMIBWnew = TRT|phase /dist=beta DDFM=KR SOLUTION;

Random DAY/residual SUBJECT=ID;