Betas loop regression

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

Kostam79
Posts: 1
Joined: Wed Oct 15, 2014 7:43 am

Betas loop regression

Postby Kostam79 » Wed Oct 15, 2014 7:54 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Betas loop regression

Postby EViews Gareth » Wed Oct 15, 2014 8:25 am

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


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest