## A problem in working with "FOR" Loop

For questions regarding programming in the EViews programming language.

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

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

### A problem in working with "FOR" Loop

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

Code: Select all

`for  !k=-7 to  0  step  0.001equation  equ1.ls  y  c  x*(x<=!k)   x*(x>!k)    m1  m2  m3series        ssr11(!k)=equ1.@ssrseries        kkk(!k)=!knext`

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.

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

### Re: A problem in working with "FOR" Loop

What are you hoping to do with this:

Code: Select all

`series        ssr11(!k)=equ1.@ssr`

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

### Re: A problem in working with "FOR" Loop

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

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

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

### Re: A problem in working with "FOR" Loop

Yes, but what exactly are you doing with that line? Explain in words what it is doing.

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

### Re: A problem in working with "FOR" Loop

EViews Gareth wrote: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: 3573
Joined: Wed Sep 17, 2008 2:25 pm

### Re: A problem in working with "FOR" Loop

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

startz wrote: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: 3573
Joined: Wed Sep 17, 2008 2:25 pm

### Re: A problem in working with "FOR" Loop

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

startz wrote: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: 3573
Joined: Wed Sep 17, 2008 2:25 pm

### Re: A problem in working with "FOR" Loop

Roughly,

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