Page 1 of 1

Help- stop the loop

Posted: Wed Jul 24, 2013 9:15 am
by junjin
Hello Everyone! Could you please help me with the codes below? My problem is that I have set the loop to be stopped when nrtf{!k}=nrtf{!j}. According to my results, nrtf3=nrtf4 but the loop does not stop and continues to produce the nrtf5 nrtf6...nrtf10. I have attached the files in this message.
Thanks you very much for the help.

'start
equation eq01
eq01.ls rt c

series nrt=@recode(rt=na,eq01.@coefs(1),rt)

equation eq02
eq02.ARCH(tdist, backcast=0.7,derive=aa) nrt c

eq02.forecast nrtf1
series nrtf1=@recode(rt=na, nrtf1,rt)

for !i = 3 to 10
!j = !i-2
!k = !i-1
equation eq{!i}
eq{!i}.ARCH(tdist,backcast=0.7,derive=aa) nrtf{!j} c

eq{!i}.forecast nrtf{!k}
series nrtf{!k} = @recode(rt=na,nrtf{!k},rt)

if nrtf{!k}=nrtf{!j}
exitloop
endif

next

Re: Help- stop the loop

Posted: Wed Jul 24, 2013 9:28 am
by EViews Gareth
You cannot use if conditions on series. I'm not sure what you're trying to do, so can't help you to do it.

Re: Help- stop the loop

Posted: Wed Jul 24, 2013 11:16 am
by junjin
You cannot use if conditions on series. I'm not sure what you're trying to do, so can't help you to do it.
Eviews Gareth, thanks a lot for the reply. If the "if condition" cannot be used on series. Could you tell me how to ask a loop to stop when coefficients of the equations are the same. For example:

'start
for !i = 3 to 10
equation eq{!i}
eq{!i}.ARCH(tdist,backcast=0.7,derive=aa) y{!i} c
next
'end

Re: Help- stop the loop

Posted: Wed Jul 24, 2013 11:23 am
by EViews Gareth
Still confused. What does checking whether two series are equal have to do with the coefficients from an equation?

To check whether the coefficients from two equations are equal, you could check the value of the maximum difference between the two sets of coefficients:

Code: Select all

!diff = @max(@abs(eq1.@coef-eq2.@coef))

Re: Help- stop the loop

Posted: Wed Jul 24, 2013 11:43 am
by junjin
Still confused. What does checking whether two series are equal have to do with the coefficients from an equation?

To check whether the coefficients from two equations are equal, you could check the value of the maximum difference between the two sets of coefficients:

Code: Select all

!diff = @max(@abs(eq1.@coef-eq2.@coef))


Eviews Gareth, thanks for your quick reply. You are right, I also confuse by myself now. I need to carefully rethinking what I was doing. Anyway, thank you very much for your help.