A problem in working with "FOR" Loop

For questions regarding programming in the EViews programming language.

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

eisamabodian
Posts: 13
Joined: Tue Aug 05, 2014 3:50 am

A problem in working with "FOR" Loop

Postby eisamabodian » Thu Jul 14, 2016 5:41 am

i have problem, when i want to run this program:

Code: Select all

for !k=-7 to 0 step 0.001 equation equ1.ls y c x*(x<=!k) x*(x>!k) m1 m2 m3 series ssr11(!k)=equ1.@ssr series kkk(!k)=!k next
this is a threshold model.i must save SSR and !k for each equation.
but negative index or decimal values are not acceptable as index for !k.
please help me.

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

Re: A problem in working with "FOR" Loop

Postby EViews Gareth » Thu Jul 14, 2016 8:14 am

What are you hoping to do with this:

Code: Select all

series ssr11(!k)=equ1.@ssr
Follow us on Twitter @IHSEViews

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

Re: A problem in working with "FOR" Loop

Postby startz » Thu Jul 14, 2016 8:52 am

Make two vectors. Store the argument k in one and the result in the other. Then index by 1,2,3...

eisamabodian
Posts: 13
Joined: Tue Aug 05, 2014 3:50 am

Re: A problem in working with "FOR" Loop

Postby eisamabodian » Thu Jul 14, 2016 9:31 am

I want to save SSR of each equation and also !k values.

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

Re: A problem in working with "FOR" Loop

Postby EViews Gareth » Thu Jul 14, 2016 11:35 am

Yes, but what exactly are you doing with that line? Explain in words what it is doing.
Follow us on Twitter @IHSEViews

eisamabodian
Posts: 13
Joined: Tue Aug 05, 2014 3:50 am

Re: A problem in working with "FOR" Loop

Postby eisamabodian » Fri Jul 15, 2016 2:01 am

Yes, but what exactly are you doing with that line? Explain in words what it is doing.
I want to save SSRs of equations and also their correspondent !k.
In threshold regression approach i must sort these variables to obtain minimum
SSR and its correspondent !k.in this situation !k is threshold value for this equation.

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

Re: A problem in working with "FOR" Loop

Postby startz » Fri Jul 15, 2016 5:36 am

Make the loop for 1 to 700. Then calculate the corresponding k.

eisamabodian
Posts: 13
Joined: Tue Aug 05, 2014 3:50 am

Re: A problem in working with "FOR" Loop

Postby eisamabodian » Sat Jul 16, 2016 7:15 am

Make the loop for 1 to 700. Then calculate the corresponding k.
This loop has 7000 numbers not 700.Another problem is this loop is for negative numbers not positive.these numbers are decimal and negative.Unfortunately Eviews doesn't accept any negative or decimal number as index.How can I solve this problem?

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

Re: A problem in working with "FOR" Loop

Postby startz » Sat Jul 16, 2016 7:18 am

Make the index 1 to 7000. .Then store the values of k in one vector and the results you want in an other. Both indexed by 1 to 7000

eisamabodian
Posts: 13
Joined: Tue Aug 05, 2014 3:50 am

Re: A problem in working with "FOR" Loop

Postby eisamabodian » Sun Jul 17, 2016 2:22 am

Make the index 1 to 7000. .Then store the values of k in one vector and the results you want in an other. Both indexed by 1 to 7000
How can I create an index from 1 to 7000?
But I need to build an index from -7 -6.999 -6.998 ........-0.003 -0.002 -0.001
Because step is 0.001
But the question is that how can I build an index from 7000 to 1 or vice versa ?Although as I said I need index in decimal form,but it seems that in Eviews we can not build indexes in decimal form.

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

Re: A problem in working with "FOR" Loop

Postby startz » Sun Jul 17, 2016 6:37 am

Roughly,

for i= 7000 to 1 step -1
k(i) = i/1000
ssr(i) = result
next

serkan
Posts: 7
Joined: Mon Dec 24, 2018 8:08 am

Re: A problem in working with "FOR" Loop

Postby serkan » Fri Jan 27, 2023 5:17 am

Hello,

I have a problem with !x loop.
Since I have negative values in !x, I cannot produce outputs of val_{!s}_{!y}_{!x} for negative ones.

for !s=1 to 3
for !y=1 to 6
for !x=-6 to 12
series val_{!s}_{!y}_{!x} = @recode(sp{!s}=1, y{!y}({!x}), 0) 'It does not produce outputs for negative !x's.
next
next
next

As a solution, I tried to sum all !x values with a constant number (such as 10), but it did not work. Please see below;
series val_{!s}_{!y}_{!x+10} = @recode(sp{!s}=1, y{!y}({!x}), 0)

I will be happy if someone helps me.
Best

Code: Select all

for !s=1 to 3 for !y=1 to 6 for !x=-6 to 12 series val_{!s}_{!y}_{!x} = @recode(sp{!s}=1, y{!y}({!x}), 0) 'It does not produce outputs for negative !x's. next next next series val_{!s}_{!y}_{!x+10} = @recode(sp{!s}=1, y{!y}({!x}), 0)

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

Re: A problem in working with "FOR" Loop

Postby EViews Gareth » Tue Jan 31, 2023 10:24 am

Its probably because series names can't have a negative sign in them, and you're using !x as part of the series name.
Follow us on Twitter @IHSEViews

serkan
Posts: 7
Joined: Mon Dec 24, 2018 8:08 am

Re: A problem in working with "FOR" Loop

Postby serkan » Mon Feb 06, 2023 12:30 am

Yes it is.
Is there a solution to covert the name of the series while using negative values in !x loop? Like multiplying by -10? Or what do you recommend?
Thanks

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

Re: A problem in working with "FOR" Loop

Postby EViews Gareth » Mon Feb 06, 2023 8:51 am

Simplest is to use the @makevalidname function.
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests