Obtaining coefficients only
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
Obtaining coefficients only
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
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
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"
Re: Obtaining coefficients only
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
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
Try
if you want the second coefficient.
Code: Select all
eq.@coefs(2)Re: Obtaining coefficients only
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
Code: Select all
equation eq{!i}.ls y{!i} c x{!i}
coefs(!rowcounter) = eq.@coef
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
Re: Obtaining coefficients only
Thank you Gareth.
Now I get the following error: non numeric argument in "COEFS(1) = EQ.1@COEF".
I really appreciate your help.
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
You need Startz's fix for that:
@coefs(2)
@coefs(2)
Re: Obtaining coefficients only
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.
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: 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.
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
Code: Select all
'counter of how many equations we have run
for !i = 1 to 72
!rowcounter=!i
next-
tchaithonov
- Posts: 168
- Joined: Mon Apr 13, 2009 7:39 am
- Location: New York City
Re: Obtaining coefficients only
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
'counter of how many equations we have run for !i = 1 to 72 !rowcounter=!i next
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
Re: Obtaining coefficients only
Thank you Tchaithonov. This is exactly what I need and it works.
Who is online
Users browsing this forum: No registered users and 0 guests
