Page 1 of 1

Betas loop regression

Posted: Wed Oct 15, 2014 7:54 am
by Kostam79
Hi, I am trying to run a program whereby I will try to capture in a coef vector the betas of a stock return vs sp500 index returns.
However, I can t retain but the last regression beta in my vector. Any help on the issue is much appreciated! Pls check below the code
BR

coef(3) betas
for %stocks mcd sbux cat
for !i=1 to 3
equation stock{%stocks}.ls d({%stocks})=c(1)+c(2)*d(spy)
betas(!i)=stock{%stocks}.@coef(2)
next
next

Re: Betas loop regression

Posted: Wed Oct 15, 2014 8:25 am
by EViews Gareth
You can't use two loops like that.

Try this:

Code: Select all

coef(3) betas !i=1 for %stocks mcd sbux cat equation stock{%stocks}.ls d({%stocks})=c(1)+c(2)*d(spy) betas(!i)=stock{%stocks}.@coef(2) !i=!i+1 next