Page 1 of 2

A problem in working with "FOR" Loop

Posted: Thu Jul 14, 2016 5:41 am
by eisamabodian
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.

Re: A problem in working with "FOR" Loop

Posted: Thu Jul 14, 2016 8:14 am
by EViews Gareth
What are you hoping to do with this:

Code: Select all

series ssr11(!k)=equ1.@ssr

Re: A problem in working with "FOR" Loop

Posted: Thu Jul 14, 2016 8:52 am
by startz
Make two vectors. Store the argument k in one and the result in the other. Then index by 1,2,3...

Re: A problem in working with "FOR" Loop

Posted: Thu Jul 14, 2016 9:31 am
by eisamabodian
I want to save SSR of each equation and also !k values.

Re: A problem in working with "FOR" Loop

Posted: Thu Jul 14, 2016 11:35 am
by EViews Gareth
Yes, but what exactly are you doing with that line? Explain in words what it is doing.

Re: A problem in working with "FOR" Loop

Posted: Fri Jul 15, 2016 2:01 am
by eisamabodian
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.

Re: A problem in working with "FOR" Loop

Posted: Fri Jul 15, 2016 5:36 am
by startz
Make the loop for 1 to 700. Then calculate the corresponding k.

Re: A problem in working with "FOR" Loop

Posted: Sat Jul 16, 2016 7:15 am
by eisamabodian
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?

Re: A problem in working with "FOR" Loop

Posted: Sat Jul 16, 2016 7:18 am
by startz
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

Re: A problem in working with "FOR" Loop

Posted: Sun Jul 17, 2016 2:22 am
by eisamabodian
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.

Re: A problem in working with "FOR" Loop

Posted: Sun Jul 17, 2016 6:37 am
by startz
Roughly,

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

Re: A problem in working with "FOR" Loop

Posted: Fri Jan 27, 2023 5:17 am
by serkan
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)

Re: A problem in working with "FOR" Loop

Posted: Tue Jan 31, 2023 10:24 am
by EViews Gareth
Its probably because series names can't have a negative sign in them, and you're using !x as part of the series name.

Re: A problem in working with "FOR" Loop

Posted: Mon Feb 06, 2023 12:30 am
by serkan
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

Re: A problem in working with "FOR" Loop

Posted: Mon Feb 06, 2023 8:51 am
by EViews Gareth
Simplest is to use the @makevalidname function.