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

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: 12540
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: 3573
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: 12540
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

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

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

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

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

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

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


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 18 guests