Obtaining coefficients only

For questions regarding programming in the EViews programming language.

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

Tadej
Posts: 11
Joined: Sun Mar 14, 2010 8:00 am
Location: Oslo, Norway

Obtaining coefficients only

Postby Tadej » Wed Mar 17, 2010 7:54 am

Hello.

Could someone please tell me what am I missing to obtain the coefficients only, from the regressions:

'create vector to store betas
vector(72) coef

'create empty equation to be used inside the loop
equation eq

''counter of how many equations we have run
!rowcounter=1

'run pairwise regressions between each y and relevant x
for !i=1 to 72
for !j=1 to 72
if !i<>!j then
equation eq{!i}.ls y{!i} c x{!i}
coefs(!rowcounter) = eq.@coef
!rowcounter = !rowcounter+1
endif
next
next

I get this error message: equation estimates are invalid or nonexistent in "COEFS(1)=EQ.@COEF"

Thank you for your help.

Best regards

startz
Non-normality and collinearity are NOT problems!
Posts: 3797
Joined: Wed Sep 17, 2008 2:25 pm

Re: Obtaining coefficients only

Postby startz » Wed Mar 17, 2010 8:12 am

You have a typo. "coef' versus "coefs"
Hello.

Could someone please tell me what am I missing to obtain the coefficients only, from the regressions:

vector(72) coef

coefs(!rowcounter) = eq.@coef

I get this error message: equation estimates are invalid or nonexistent in "COEFS(1)=EQ.@COEF"

Tadej
Posts: 11
Joined: Sun Mar 14, 2010 8:00 am
Location: Oslo, Norway

Re: Obtaining coefficients only

Postby Tadej » Wed Mar 17, 2010 8:23 am

Thank you startz for the reply. This though stil doesn't fix the problem. I am stil getting the same error message.

Maybe if you try it yourself:

'create a workfile
wfcreate d 2004 2010

'create 72 y series
for !i=1 to 72
series y{!i}=nrnd
next

'create 72 X series
for !i=1 to 72
series x{!i}=nrnd
next

'create vector to store betas
vector(72) coef

'create empty equation to be used inside the loop
equation eq

''counter of how many equations we have run
!rowcounter=1

'run pairwise regressions between each y and relevant x
for !i=1 to 72
for !j=1 to 72
if !i<>!j then
equation eq{!i}.ls y{!i} c x{!i}
coef(!rowcounter) = eq.@coef
!rowcounter = !rowcounter+1
endif
next
next

startz
Non-normality and collinearity are NOT problems!
Posts: 3797
Joined: Wed Sep 17, 2008 2:25 pm

Re: Obtaining coefficients only

Postby startz » Wed Mar 17, 2010 8:58 am

Try

Code: Select all

eq.@coefs(2)
if you want the second coefficient.

Tadej
Posts: 11
Joined: Sun Mar 14, 2010 8:00 am
Location: Oslo, Norway

Re: Obtaining coefficients only

Postby Tadej » Wed Mar 17, 2010 9:30 am

I still get the error message of: equation estimates are invalid or nonexistent in "COEFS(1)=EQ.@COEF". Something else must be missing in the program...Any idea?

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

Re: Obtaining coefficients only

Postby EViews Gareth » Wed Mar 17, 2010 9:40 am

Code: Select all

equation eq{!i}.ls y{!i} c x{!i} coefs(!rowcounter) = eq.@coef
You're creating an equation called eq{!i}, but you're referencing an equation called eq.

You probably want to change your code to be:

Code: Select all

equation eq{!i}.ls y{!i} c x{!i} coefs(!rowcounter) = eq{!i}.@coef

Tadej
Posts: 11
Joined: Sun Mar 14, 2010 8:00 am
Location: Oslo, Norway

Re: Obtaining coefficients only

Postby Tadej » Wed Mar 17, 2010 9:58 am

Thank you Gareth.

Now I get the following error: non numeric argument in "COEFS(1) = EQ.1@COEF".

I really appreciate your help.

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

Re: Obtaining coefficients only

Postby EViews Gareth » Wed Mar 17, 2010 10:58 am

You need Startz's fix for that:
@coefs(2)

Tadej
Posts: 11
Joined: Sun Mar 14, 2010 8:00 am
Location: Oslo, Norway

Re: Obtaining coefficients only

Postby Tadej » Wed Mar 17, 2010 5:22 pm

Class guys, thanks a lot. Now I don't get an error message anymore. However, the vector beta still doesn't contain coefficients after I run the program.

Code: Select all

create vector to store betas vector(72) coefs 'counter of how many equations we have run !rowcounter=1 'run pairwise regressions between each series for !i=1 to 72 for !j=1 to 72 if !i<>!j then equation eq{!i}.ls y{!i} c x{!i} coefs(!rowcounter)=eq{!i}.@coefs(2) endif next next
I think the problem lies in rowcounter. Since if I set it to 72 (!rowcounter=72) I get the right coefficient saved in the coefs vector but only for the 72nd equation. It's the same if I specify:

Code: Select all

'counter of how many equations we have run for !i = 1 to 72 !rowcounter=!i next
What am I still doing wrong? I am feeling silly already since I am posting so many questions. I appologize for that but as you know this is the first time I write the programming language.

tchaithonov
Posts: 168
Joined: Mon Apr 13, 2009 7:39 am
Location: New York City

Re: Obtaining coefficients only

Postby tchaithonov » Thu Mar 18, 2010 8:01 am

Code: Select all

'counter of how many equations we have run for !i = 1 to 72 !rowcounter=!i next
What you are doing here is just changing !rowcounter within a loop and then do nothing afterwards. If you need move to the next element in the coef vector, you need to do this:

Code: Select all

create vector to store betas vector(72) coefs 'run pairwise regressions between each series for !i=1 to 72 !rowcounter = !i for !j=1 to 72 if !i<>!j then equation eq{!i}.ls y{!i} c x{!i} coefs(!rowcounter)=eq{!i}.@coefs(2) endif next next

Tadej
Posts: 11
Joined: Sun Mar 14, 2010 8:00 am
Location: Oslo, Norway

Re: Obtaining coefficients only

Postby Tadej » Thu Mar 18, 2010 8:33 am

Thank you Tchaithonov. This is exactly what I need and it works.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 0 guests